[ruby-core:120538] [Ruby master Bug#21014] Prism doesn't set node_id on iseqs correctly

Issue #21014 has been reported by tenderlovemaking (Aaron Patterson). ---------------------------------------- Bug #21014: Prism doesn't set node_id on iseqs correctly https://bugs.ruby-lang.org/issues/21014 * Author: tenderlovemaking (Aaron Patterson) * Status: Open * Assignee: prism * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- Given this code: ```ruby f = proc { <<END } heredoc END iseq = RubyVM::InstructionSequence.of(f) p iseq.to_a[4][:node_id] ``` Output on parse.y: ``` $ ./miniruby --parser=parse.y test.rb 3 ``` Output on Prism: ``` $ ./miniruby test.rb -1 ``` I don't expect node IDs on Prism to match parse.y, but I do expect the node id to be a legitimate node id. For example, this program should work: ```ruby f = proc { <<END } heredoc END iseq = RubyVM::InstructionSequence.of(f) require "prism" node_id = iseq.to_a[4][:node_id] ast = Prism.parse(File.binread(__FILE__)) p ast.value.breadth_first_search { |node| node.node_id == node_id } ``` -- https://bugs.ruby-lang.org/

Issue #21014 has been updated by tenderlovemaking (Aaron Patterson). Fix sent here: https://github.com/ruby/ruby/pull/12527 ---------------------------------------- Bug #21014: Prism doesn't set node_id on iseqs correctly https://bugs.ruby-lang.org/issues/21014#change-111340 * Author: tenderlovemaking (Aaron Patterson) * Status: Open * Assignee: prism * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- Given this code: ```ruby f = proc { <<END } heredoc END iseq = RubyVM::InstructionSequence.of(f) p iseq.to_a[4][:node_id] ``` Output on parse.y: ``` $ ./miniruby --parser=parse.y test.rb 3 ``` Output on Prism: ``` $ ./miniruby test.rb -1 ``` I don't expect node IDs on Prism to match parse.y, but I do expect the node id to be a legitimate node id. For example, this program should work: ```ruby f = proc { <<END } heredoc END iseq = RubyVM::InstructionSequence.of(f) require "prism" node_id = iseq.to_a[4][:node_id] ast = Prism.parse(File.binread(__FILE__)) p ast.value.breadth_first_search { |node| node.node_id == node_id } ``` -- https://bugs.ruby-lang.org/

Issue #21014 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: REQUIRED to 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: DONE ruby_3_4 commit:9240f01b1fbe5ea4f6a2017d35f8f605f84f0039 merged revision(s) commit:63723c8d5908569918fb27e070ae5bc9de33c8bd. ---------------------------------------- Bug #21014: Prism doesn't set node_id on iseqs correctly https://bugs.ruby-lang.org/issues/21014#change-111918 * Author: tenderlovemaking (Aaron Patterson) * Status: Closed * Assignee: prism * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: DONE ---------------------------------------- Given this code: ```ruby f = proc { <<END } heredoc END iseq = RubyVM::InstructionSequence.of(f) p iseq.to_a[4][:node_id] ``` Output on parse.y: ``` $ ./miniruby --parser=parse.y test.rb 3 ``` Output on Prism: ``` $ ./miniruby test.rb -1 ``` I don't expect node IDs on Prism to match parse.y, but I do expect the node id to be a legitimate node id. For example, this program should work: ```ruby f = proc { <<END } heredoc END iseq = RubyVM::InstructionSequence.of(f) require "prism" node_id = iseq.to_a[4][:node_id] ast = Prism.parse(File.binread(__FILE__)) p ast.value.breadth_first_search { |node| node.node_id == node_id } ``` -- https://bugs.ruby-lang.org/
participants (2)
-
k0kubun (Takashi Kokubun)
-
tenderlovemaking (Aaron Patterson)