Issue #19451 has been updated by ioquatix (Samuel Williams).
@nobu most text editors need a single line and column for each backtrace location.
As it stands, just looking at the backtrack locations is not enough. For `SyntaxError`,
the editor needs to know the "first location" which is the point the syntax
error occurred.
There are two ways this can be done:
(1) SyntaxError#path / #line / #column information + SyntaxError#backtrace_locations
(2) SyntaxError#backtrace_locations[0] contains the above `#path` `#line` and `#column`
information, followed by the normal backtrace.
By "prepend them to the backtrace_locations" I mean option (2), which is far
easier for the editor to consume, since it won't have to know the specific details of
how "SyntaxError" works, it will just put markers at each `backtrace_locations`,
with the error details itself on `backtrace_locations[0]`.
----------------------------------------
Feature #19451: Extract path and line number from SyntaxError?
https://bugs.ruby-lang.org/issues/19451#change-101963
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
----------------------------------------
There doesn't seem to be any official way to extract the path and line number from a
syntax error.
There are two ways I can see us dong this:
- Provide explicit `path` and `line_number` attributes.
- Prepend them to `backtrace_locations`.
The nice thing about the latter approach is that it will just work with existing tools
which understand how to highlight code based on backtrace locations.
Maybe we should do both?
--
https://bugs.ruby-lang.org/