Skip to content

Commit a54abc4

Browse files
committed
When parsing an invalid write, still add to the local table
1 parent 9bdd59b commit a54abc4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/prism.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13695,7 +13695,7 @@ parse_unwriteable_write(pm_parser_t *parser, pm_node_t *target, const pm_token_t
1369513695
default: break;
1369613696
}
1369713697

13698-
pm_constant_id_t name = pm_parser_constant_id_location(parser, target->location.start, target->location.end);
13698+
pm_constant_id_t name = pm_parser_local_add_location(parser, target->location.start, target->location.end, 1);
1369913699
pm_local_variable_write_node_t *result = pm_local_variable_write_node_create(parser, name, 0, value, &target->location, equals);
1370013700

1370113701
pm_node_destroy(parser, target);

test/prism/locals_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
# to test on the most recent versions.
1010
return if !defined?(RubyVM::InstructionSequence) || RUBY_VERSION < "3.4.0"
1111

12+
# In Ruby 3.4.0, the local table for method forwarding changed. But 3.4.0 can
13+
# refer to the dev version, so while 3.4.0 still isn't released, we need to
14+
# check if we have a high enough revision.
15+
return if RubyVM::InstructionSequence.compile("def foo(...); end").to_a[13][2][2][10].length != 1
16+
1217
# Omit tests if running on a 32-bit machine because there is a bug with how
1318
# Ruby is handling large ISeqs on 32-bit machines
1419
return if RUBY_PLATFORM =~ /i686/

0 commit comments

Comments
 (0)