diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-07-12 09:27:32 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-07-12 13:50:00 +0000 |
| commit | 6298667ff55126106dad8448096de3ed975f6644 (patch) | |
| tree | 7deec4e3a294424abb1dccf27e1b036bf24abc29 | |
| parent | ca99f86bd6157a3268a63ba36bda49c140428752 (diff) | |
[ruby/prism] When parsing an invalid write, still add to the local table
https://github.com/ruby/prism/commit/a54abc4d1b
| -rw-r--r-- | prism/prism.c | 2 | ||||
| -rw-r--r-- | test/prism/locals_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c index 73df294213..d46c06c58d 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -13695,7 +13695,7 @@ parse_unwriteable_write(pm_parser_t *parser, pm_node_t *target, const pm_token_t default: break; } - pm_constant_id_t name = pm_parser_constant_id_location(parser, target->location.start, target->location.end); + pm_constant_id_t name = pm_parser_local_add_location(parser, target->location.start, target->location.end, 1); pm_local_variable_write_node_t *result = pm_local_variable_write_node_create(parser, name, 0, value, &target->location, equals); pm_node_destroy(parser, target); diff --git a/test/prism/locals_test.rb b/test/prism/locals_test.rb index 3c45d8b08b..ea61fd9499 100644 --- a/test/prism/locals_test.rb +++ b/test/prism/locals_test.rb @@ -9,6 +9,11 @@ # to test on the most recent versions. return if !defined?(RubyVM::InstructionSequence) || RUBY_VERSION < "3.4.0" +# In Ruby 3.4.0, the local table for method forwarding changed. But 3.4.0 can +# refer to the dev version, so while 3.4.0 still isn't released, we need to +# check if we have a high enough revision. +return if RubyVM::InstructionSequence.compile("def foo(...); end").to_a[13][2][2][10].length != 1 + # Omit tests if running on a 32-bit machine because there is a bug with how # Ruby is handling large ISeqs on 32-bit machines return if RUBY_PLATFORM =~ /i686/ |
