diff options
| author | Luke Gruber <luke.gru@gmail.com> | 2024-09-29 12:39:23 -0400 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu.nakada@gmail.com> | 2024-10-01 02:12:56 +0900 |
| commit | d592ddd5e619ffe1691b8050de2ccc3e1bd6e080 (patch) | |
| tree | 01102e6ea49ef52cf3c8ad4c5d1124d8ec088efc /tool/lib | |
| parent | 2a58092360c70caf7544544c95549b4c83e81237 (diff) | |
Fix compile issue with a short-circuited if/unless condition and `defined?`
This caused an issue when `defined?` was in the `if` condition. Its
instructions weren't appended to the instruction sequence even though it was compiled
if a compile-time known logical short-circuit happened before the `defined?`. The catch table
entry (`defined?` compilation produces a catch table entry) was still on the iseq even though the
instructions weren't there. This caused faulty exception handling in the method.
The solution is to no add the catch table entry for `defined?` after a compile-time known logical
short circuit.
This shouldn't touch much code, it's only for cases like the following,
which can occur during debugging:
if false && defined?(Some::CONSTANT)
"more code..."
end
Fixes [Bug #20501]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/11554
Diffstat (limited to 'tool/lib')
| -rw-r--r-- | tool/lib/envutil.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb index 642965047f..952614b8cf 100644 --- a/tool/lib/envutil.rb +++ b/tool/lib/envutil.rb @@ -165,6 +165,11 @@ module EnvUtil } args = [args] if args.kind_of?(String) + # use the same parser as current ruby + if args.none? { |arg| arg.start_with?("--parser=") } + current_parser = RUBY_DESCRIPTION =~ /prism/i ? "prism" : "parse.y" + args = ["--parser=#{current_parser}"] + args + end pid = spawn(child_env, *precommand, rubybin, *args, opt) in_c.close out_c&.close |
