Project

General

Profile

Actions

Bug #21014

closed

Prism doesn't set node_id on iseqs correctly

Added by tenderlovemaking (Aaron Patterson) 17 days ago. Updated 13 days ago.

Status:
Closed
Assignee:
Target version:
-
[ruby-core:120538]

Description

Given this code:

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:

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 }
Actions #2

Updated by tenderlovemaking (Aaron Patterson) 17 days ago

  • Status changed from Open to Closed

Applied in changeset git|63723c8d5908569918fb27e070ae5bc9de33c8bd.


Correctly set node_id on iseq location

The iseq location object has a slot for node ids. parse.y was correctly
populating that field but Prism was not. This commit populates the field
with the ast node id for that iseq

[Bug #21014]

Actions #3

Updated by kddnewton (Kevin Newton) 13 days ago

  • Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: REQUIRED
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0