Yusuke Endoh and Claude Opus 5.5
c9fd48603c
[ruby/error_highlight] Prefer Ruby::Prism, the parser built into the interpreter
...
Ruby 4.1 will expose the prism parser built into the interpreter as
Ruby::Prism, and the prism gem becomes a bundled gem
(https://bugs.ruby-lang.org/issues/22379 ). Ruby::Prism is the very
parser that compiled the code, so use it for spotting nodes; the prism
gem is not needed and may not be available under bundler. On older
Rubies keep using the prism gem as before.
The constant-path checks use Node#type instead of class comparisons so
that they work with nodes of either module.
https://github.com/ruby/error_highlight/commit/ae50da6cc4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-10-08 07:37:45 +00:00
Benoit Daloze
cc32a3031e
[ruby/error_highlight] Use Thread::Backtrace::Location#syntax_tree when available
...
https://github.com/ruby/error_highlight/commit/7755b9bff1
2026-09-24 08:19:27 +00:00
Marco Roth
ab2cb306e4
[ruby/error_highlight] Handle nil backtrace_locations in generate_snippet
...
https://github.com/ruby/error_highlight/commit/3e223e39e1
2026-07-08 15:43:06 +00:00
Yusuke Endoh
feb0b2849f
[ruby/error_highlight] Bump version to 0.7.2
...
https://github.com/ruby/error_highlight/commit/d945ffd2aa
2026-06-26 07:08:41 +00:00
Randy Stauner
12ef8a66ab
[ruby/error_highlight] Return nil instead of raising NotImplementedError for def/lambda/block args
...
ErrorHighlight.spot defaults point_type to :args for ArgumentError. When an
ArgumentError originates from argument binding (e.g. a missing required
keyword), its first backtrace location maps to a def/lambda/block node. The
spotter had no implementation for the :args point type on those nodes and did
`raise NotImplementedError`.
This is a regression from 0.7.0 (and in Ruby 4.0 compared to Ruby 3.4).
ErrorHighlight.spot only rescues SyntaxError/SystemCallError/ArgumentError, and
NotImplementedError is not a StandardError, so it escaped through
CoreExt#generate_snippet -> Exception#detailed_message / #full_message and
replaced the original exception. This is normally hidden because the VM's
"missing keyword" message matches the keyword regex in generate_snippet and
takes the safe :name branch, but it surfaces as soon as the ArgumentError is
re-raised/wrapped with a custom message that falls into the :args else branch.
Return nil (the documented "no spot" result) for these cases instead, matching
the graceful-degradation behavior of the surrounding feature. The fix is
applied consistently across both compilers:
- prism: def_node / lambda_node / block_node
- parse.y: DEFN / DEFS (raised NotImplementedError) and LAMBDA / ITER
(silently returned a spot for :args, inconsistent with prism)
All of these branches were introduced together by the experimental "wrong
number of arguments" snippet feature and are only intended for point_type
:name, so returning nil for any other point_type keeps the two parsers in sync.
https://github.com/ruby/error_highlight/commit/ca126db2db
2026-06-25 05:57:27 +00:00
BurdetteLamar
d79ce7e4e9
[ruby/error_highlight] [DOC] Fix link in ErrorHighlight
...
https://github.com/ruby/error_highlight/commit/6096a05b2f
2026-02-06 23:32:33 +00:00
Yusuke Endoh
8eaf6739fd
[ruby/error_highlight] Bump version
...
https://github.com/ruby/error_highlight/commit/dc2dad6632
2025-12-23 13:03:02 +09:00
Yusuke Endoh
aee4b24829
[ruby/error_highlight] Show no message when failing to get caller/callee snippets
...
Even with Ruby 4.0, snippets is not always available, such as in irb by
default. It would be better to just say nothing than to show a confusing
message.
https://github.com/ruby/error_highlight/commit/ef80ce73a1
2025-12-17 21:11:27 +09:00
John Hawthorn
4e1f20fee6
[ruby/error_highlight] Fix prism_spot_def_for_name for singletons
...
Previously calling a singleton method with invalid arguments would give:
RuntimeError: Incompatible locations
This is because `join` wants the operator to come before the location
https://github.com/ruby/error_highlight/commit/44920551dd
2025-11-19 22:27:28 +00:00
Yasuo Honda
da114dfe0b
[ruby/error_highlight] Replace Ruby 3.5 with Ruby 4.0
...
This commit updates the Ruby version to follow the commit in Ruby master branch.
https://github.com/ruby/ruby/commit/6d81969b475262aba251e99b518181bdf7c5a523
https://github.com/ruby/error_highlight/commit/dcecf68d75
2025-11-12 10:14:56 +09:00
Aaron Patterson
78e4a36fb1
[ruby/error_highlight] Support cases where there are multiple missing / wrong kwargs
...
This commit fixes the case when there are multiple missing or incorrect
keywords provided to a method. Without this fix, ErrorHighlight itself
will raise an exception
https://github.com/ruby/error_highlight/commit/8bde92b36e
2025-10-30 00:43:30 +00:00
Yusuke Endoh
c693b0e477
[ruby/error_highlight] Improve English comments and messages
...
https://github.com/ruby/error_highlight/commit/5f976265ef
2025-10-07 09:07:22 +00:00
Yusuke Endoh
b85b2b84ad
[ruby/error_highlight] Remove a branch for Ruby 3.1
...
https://github.com/ruby/error_highlight/commit/d3063cde62
2025-08-28 06:35:10 +00:00
Yusuke Endoh
2e27f6e1f1
[ruby/error_highlight] Drop Ruby 3.1 support
...
... as it is already EOL
https://github.com/ruby/error_highlight/commit/f15489216a
2025-08-28 06:35:10 +00:00
Yusuke Endoh
85e0c98cf0
[ruby/error_highlight] Show a dedicated snippet for "wrong number of arguments" error
...
This is an experimental implementation for
https://bugs.ruby-lang.org/issues/21543 .
```
test.rb:2:in 'Object#foo': wrong number of arguments (given 1, expected 2) (ArgumentError)
caller: test.rb:6
| foo(1)
^^^
callee: test.rb:2
| def foo(x, y)
^^^
from test.rb:6:in 'Object#bar'
from test.rb:10:in 'Object#baz'
from test.rb:13:in '<main>'
```
https://github.com/ruby/error_highlight/commit/21e974e1c4
2025-08-28 06:26:06 +00:00
Yusuke Endoh
e01b4ca1c8
[ruby/error_highlight] Ensure first_line and last_line are set
...
Fixes https://github.com/ruby/error_highlight/pull/58
https://github.com/ruby/error_highlight/commit/9ddc1f31a9
2025-01-29 08:51:42 +00:00
wanabe
e5f81e511f
[ruby/error_highlight] Use $stderr instead of STDERR for Ractor
...
https://github.com/ruby/error_highlight/commit/a221a4b0eb
2025-01-21 03:32:15 +00:00
Yusuke Endoh
043f26edee
[ruby/error_highlight] Bump version
...
https://github.com/ruby/error_highlight/commit/a8e9eb7f2f
2024-12-03 03:11:18 +00:00
Guilherme Carreiro
0b3d518e81
[ruby/error_highlight] Rename the ErrorHighlight::DefaultFormatter setting to max_snippet_width for clarity
...
https://github.com/ruby/error_highlight/commit/e13cbd4335
2024-10-24 00:29:20 +00:00
Guilherme Carreiro
e9ba6c2ea4
[ruby/error_highlight] Adjust truncation, add opt-out mechanism, rename methods, and prepare error highlighting to render on extremely small screens
...
https://github.com/ruby/error_highlight/commit/c565340958
2024-10-23 00:58:50 +00:00
Guilherme Carreiro
e7c9dfb3e9
[ruby/error_highlight] Handle very long lines with errors in the middle of the line
...
https://github.com/ruby/error_highlight/commit/0657bc1afa
2024-10-23 00:58:50 +00:00
Guilherme Carreiro
5aa8b9e3b5
[ruby/error_highlight] Handle very long lines
...
https://github.com/ruby/error_highlight/commit/383490a4b4
2024-10-23 00:58:50 +00:00
Luke Gruber
2a0ee408af
[ruby/error_highlight] Fix error with prism when method given no arguments
...
such as:
p = Proc.new
This now matches the RubyVM::AbstractSyntaxTree behavior, which is
not to highlight anything.
https://github.com/ruby/error_highlight/commit/d5c592a1ba
2024-09-24 13:28:01 +00:00
Adam Hess
4b1e852d3e
[ruby/error_highlight] Prism added node_id and Node#breadth_first_search in the 1.0 release. These methods are required for Prism to be able to find the method from the backtrace.
...
https://github.com/ruby/prism/blob/main/CHANGELOG.md#100---2024-08-28
In practice you will likely only end up in this situation if you previously had pre-1.0 prism installed and upgrade Ruby to a version with Prism as the default parser.
https://github.com/ruby/error_highlight/commit/cb574daf62
2024-09-24 15:33:31 +09:00
Kevin Newton
c1df15c3e6
[PRISM] Use node ids for error highlight
2024-07-11 14:25:54 -04:00
Kevin Newton
51bb5dcd2e
[ruby/error_highlight] Trim trailing spaces in base.rb
...
https://github.com/ruby/error_highlight/commit/8ce3f6f145
2024-06-07 13:28:23 +00:00
Kevin Newton
40ec860de7
[ruby/error_highlight] Support for the prism compiler
...
https://github.com/ruby/error_highlight/commit/69fbacfd49
2024-06-07 13:15:14 +00:00
Kevin Newton
82a4c3af16
Add error for iseqs compiled by prism
2024-02-21 11:44:40 -05:00
Yusuke Endoh
edb8fc24d4
[ruby/error_highlight] Bump version
...
https://github.com/ruby/error_highlight/commit/942a723d32
2023-12-09 08:34:08 +00:00
Yusuke Endoh
94d6d6d93f
[ruby/error_highlight] Identify which node in Foo::Bar::Baz causes a NameError
...
In Ruby 3.2 or later, a nested constant access like `Foo::Bar::Baz` is
compiled to one instruction by the optimization https://github.com/ruby/ruby/pull/6187
We try to spot which sub-node caues a NameError in question based on the
constant name. We will give up if the same constant name is accessed in
a nested access (`Foo::Foo`).
Fixes https://github.com/ruby/error_highlight/pull/31
https://github.com/ruby/error_highlight/commit/0a4db7da0a
2023-01-13 08:25:09 +00:00
Yusuke Endoh
d019c3a4bd
[ruby/error_highlight] Bump version
...
https://github.com/ruby/error_highlight/commit/5275078dc6
2022-11-14 06:37:33 +00:00
Yusuke Endoh
8bfd4dd4e1
[ruby/error_highlight] Enable ErrorHighlight for TypeError/ArgumentError only after Ruby 3.2
...
... because changing TypeError#message and ArgumentError#message is
highly incompatible.
https://github.com/ruby/error_highlight/commit/39aa897c7a
2022-11-14 06:06:12 +00:00
Yusuke Endoh
4e728486b9
[ruby/error_highlight] Bump version
...
https://github.com/ruby/error_highlight/commit/59c291cce1
2022-11-08 08:07:39 +00:00
eileencodes and Aaron Patterson
350d0aa023
[ruby/error_highlight] Support nodes in spot
...
Fixes a bug where `spot` was using the wrong local variable.
We want to use error highlight with code that has been eval'd,
specifically ERB templates. We can recover the compiled source code of
the ERB template but we need an API to pass the node into error
highlight's `spot`.
Required Ruby PR: https://github.com/ruby/ruby/pull/6593
https://github.com/ruby/error_highlight/commit/0b1b650a59
Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org >
2022-10-31 04:58:38 +00:00
Yusuke Endoh
6bcb473d9c
[ruby/error_highlight] Apply ErrorHighlight::CoreExt to TypeError and ArgumentError
...
https://github.com/ruby/error_highlight/commit/defcaf1beb
2022-08-19 18:34:15 +09:00
Yusuke Endoh
d9f1b8baa3
[ruby/error_highlight] Add a note about the current limitation of ErrorHighlight.spot
...
https://github.com/ruby/error_highlight/commit/489ce80a62
2022-08-12 14:04:41 +09:00
Yusuke Endoh
1b32a4c7bb
[ruby/error_highlight] Bump version
...
https://github.com/ruby/error_highlight/commit/6edf0a0a5d
2022-08-10 21:51:51 +09:00
Yusuke Endoh
3a58009066
[ruby/error_highlight] Make backtrace_location keyword work
...
We had to keep backtrace_location before opts is overwritten.
https://github.com/ruby/error_highlight/commit/2735e4681a
2022-08-10 21:19:10 +09:00
Yusuke Endoh
99e7fa5b37
[ruby/error_highlight] Make ErrorHighlight.spot accept Exception ( https://github.com/ruby/error_highlight/pull/25 )
...
... and move things from core_ext.rb to base.rb.
This will confine CRuby-dependent things to ErrorHighlight.spot.
https://github.com/ruby/error_highlight/commit/22d1dd7824
2022-08-10 18:37:13 +09:00
Yusuke Endoh
f075be3dcb
[ruby/error_highlight] Use Exception#detailed_message instead of overriding #message ( https://github.com/ruby/error_highlight/pull/24 )
...
See https://bugs.ruby-lang.org/issues/18564 .
Ref: https://github.com/ruby/did_you_mean/pull/177
https://github.com/ruby/error_highlight/commit/671b7c61b2
2022-06-07 17:40:19 +09:00
Christian Boos
11b1ebe606
[ruby/error_highlight] Fix the spurious TypeError.
...
When we have no backtrace locations, we can't have the highlight,
so just return the message.
https://github.com/ruby/error_highlight/commit/9f5c639494
2022-01-04 23:09:01 +09:00
Yusuke Endoh
d5019949b5
[ruby/error_highlight] Bump version
...
https://github.com/ruby/error_highlight/commit/ae3053686f
2021-12-23 12:56:07 +09:00
Yusuke Endoh
52b1c76534
Manually sync https://github.com/ruby/error_highlight/commit/d2140d795ad0a06398db81739201877d431755db
2021-12-19 04:13:14 +09:00
Yusuke Endoh
acac2b8128
Make RubyVM::AbstractSyntaxTree.of raise for backtrace location in eval
...
This check is needed to fix a bug of error_highlight when NameError
occurred in eval'ed code.
https://github.com/ruby/error_highlight/pull/16
The same check for proc/method has been already introduced since
64ac984129 .
2021-12-19 03:51:37 +09:00
Yusuke Endoh
dc46529b64
[ruby/error_highlight] Ignore all syscall errors
...
At least, Error::ENOTSUP may be raised on some extreme environments
https://github.com/ruby/error_highlight/commit/2787983ff7
2021-11-30 13:49:04 +09:00
Yusuke Endoh
4c32fcb84f
[ruby/error_highlight] Make the formatter mechanism support Ractor
...
Now the formatter configuration is per Ractor. DefaultFormatter is used
if not set.
DefaultFormatter#message_for is now a class method to allow sub-Ractors
to call the method.
https://github.com/ruby/error_highlight/commit/9fbaa8ab7c
2021-10-27 11:29:20 +09:00
Yusuke Endoh
cad83fa3c4
ast.c: Rename "save_script_lines" to "keep_script_lines"
...
... as per ko1's preference. He is preparing to extend this feature to
ISeq for his new debugger. He prefers "keep" to "save" for this wording.
This API is internal and not included in any released version, so I
change it in advance.
2021-08-20 16:18:36 +09:00
Masataka Pocke Kuwabara
242f024bcb
[ruby/error_highlight] Keep it work if paren exists after receiver
...
https://github.com/ruby/error_highlight/commit/b79d679bbd
2021-07-31 22:15:16 +09:00
Yusuke Endoh
5fd5d71a4b
[ruby/error_highlight] Support a file that has no final newline
...
https://github.com/ruby/error_highlight/commit/9d671284cb
2021-07-13 16:54:17 +09:00
Yusuke Endoh
23c8bc367c
[ruby/error_highlight] Support hard tabs
...
Now, the highlight line is created by replacing non-tab characters with
spaces, and keeping all hard tabs as-is. This means the highlight line
has the completely same indentation as the code snippet line.
Fixes #7
https://github.com/ruby/error_highlight/commit/38f20fa542
2021-07-13 16:51:02 +09:00