summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2023-12-12 14:24:00 -0500
committerJemma Issroff <jemmaissroff@gmail.com>2023-12-13 08:11:21 -0500
commit1ad991c54d7d890527050a54899265da21a677c2 (patch)
tree7f09e8847bae6ece72acbf559c601f4649fad830 /test/ruby
parent36ca99b343ee8847beb4b7e0be112f75af64109f (diff)
[PRISM] Fix attrset edge cases
In some cases code may look like an attrset ID but should actually return the value of the method, not the passed values. In ruby/prism#2051 a flag was added when we have a attribute write call. I used this flag to add the proper instructions when we have a real attrset instead of using `rb_is_attrset_id` which was kind of hacky anyway. The value that should be returned in the newly added test is 42, not 2. Previously the changes we had made returned 2. Related to ruby/prism#1715
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_compile_prism.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index f5849afd83..4f81e8fde3 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -1412,6 +1412,12 @@ module Prism
CODE
assert_prism_eval(<<-CODE)
+ foo = Object.new
+ def foo.[]=(k,v); 42; end
+ foo.[]=(1,2)
+ CODE
+
+ assert_prism_eval(<<-CODE)
def self.prism_opt_var_trail_hash(a = nil, *b, c, **d); end
prism_opt_var_trail_hash("a")
prism_opt_var_trail_hash("a", c: 1)