summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2023-12-14 12:20:24 -0500
committerJemma Issroff <jemmaissroff@gmail.com>2023-12-14 13:48:38 -0500
commit5a66832952fa1ee971406b797605f72cead6e9c4 (patch)
treeae720fe7c3a130993dc7e4f19e84289712a80807 /test/ruby
parent7ac93e99a3db30ed41cbbe95df1d7be9a790b9cb (diff)
[Prism] Fix cvar or assignment instructions
The instructions for `PM_CLASS_VARIABLE_OR_WRITE_NODE` were incorrect as they were missing a `putnil`, a `defined`, and a `branchunless`. I verified this is fixed via the instructions and running the following: `RUBY_ISEQ_DUMP_DEBUG=prism make test/csv/interface/test_read_write.rb`. These new instructions can't go in the defined function because `defined?(@@fop ||= 1)` should return "assignment" not "class variable". Instructions before: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(30,11)> 0000 putnil ( 30)[Li] 0001 defined class variable, :@@foo, true 0005 branchunless 14 0007 getclassvariable :@@foo, <is:0> 0010 dup 0011 branchif 20 0013 pop 0014 putobject 1 0016 dup 0017 setclassvariable :@@foo, <is:0> 0020 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:29 (29,0)-(29,11)> 0000 getclassvariable :@@foo, <is:0> ( 29)[Li] 0003 dup 0004 branchif 13 0006 pop 0007 putobject 1 0009 dup 0010 setclassvariable :@@foo, <is:0> 0013 leave ``` Instructions after: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(30,11)> 0000 putnil ( 30)[Li] 0001 defined class variable, :@@foo, true 0005 branchunless 14 0007 getclassvariable :@@foo, <is:0> 0010 dup 0011 branchif 20 0013 pop 0014 putobject 1 0016 dup 0017 setclassvariable :@@foo, <is:0> 0020 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:29 (29,0)-(29,11)> 0000 putnil ( 29)[Li] 0001 defined class variable, :@@foo, true 0005 branchunless 14 0007 getclassvariable :@@foo, <is:0> 0010 dup 0011 branchif 20 0013 pop 0014 putobject 1 0016 dup 0017 setclassvariable :@@foo, <is:0> 0020 leave ``` Fixes ruby/prism#2064
Diffstat (limited to 'test/ruby')
0 files changed, 0 insertions, 0 deletions