Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnsureNode SourceSection does not cover the full try part, and not the ensure part #2758

Closed
eregon opened this issue Oct 7, 2022 · 2 comments · Fixed by #2761
Closed

EnsureNode SourceSection does not cover the full try part, and not the ensure part #2758

eregon opened this issue Oct 7, 2022 · 2 comments · Fixed by #2761
Assignees
Labels

Comments

@eregon
Copy link
Member

eregon commented Oct 7, 2022

Instead it seems to only cover the first line.
Debugged with @nirvdrum, the EnsureNode SourceSection only covers line 8, while the tryPart is a SequenceNode covering lines 8 and 9. The zsuper is at line 9 and can't have a breakpoint, most likely due to this.

@eregon eregon added the tooling label Oct 7, 2022
@eregon eregon self-assigned this Oct 7, 2022
@eregon
Copy link
Member Author

eregon commented Oct 10, 2022

NodeUtil.printSourceAttributionTree() is quite useful for this:

def foo
  begin
    body1
    body2
  ensure
    guaranteed1
    guaranteed2
  end
end

Truffle::Debug.print_source_sections(method(:foo))

gives

Full source len=(139)  ___def foo
  begin
    body1
    body2
  ensure
    guaranteed1
    guaranteed2
  end
end

Truffle::Debug.print_source_sections(method(:foo))
___
AST source attribution:
|   (RubyMethodRootNode)  SourceSection(source=ensure_lines.rb [1:1 - 9:3], index=0, length=86, characters=def foo\n  begin\n    body1\n    body2\n  ensure\n    guaranteed1\n    guaranteed2\n  end\nend)source: (0,85) line=1 len=86 text="def foo
  begin
    body1
    body2
  ensure
    guaranteed1
    guaranteed2
  end
end"
| | body  (SequenceNode)  SourceSection(source=ensure_lines.rb [1:1 - 9:3], index=0, length=86, characters=def foo\n  begin\n    body1\n    body2\n  ensure\n    guaranteed1\n    guaranteed2\n  end\nend)source: (0,85) line=1 len=86 text="def foo
  begin
    body1
    body2
  ensure
    guaranteed1
    guaranteed2
  end
end"
| | | body[0]  (WriteLocalVariableNode)  
| | | | valueNode  (ProfileArgumentNodeGen)  
| | | | | child_  (ReadSelfNode)  
| | | body[1]  (SaveMethodBlockNode)  
| | | body[2]  (EnsureNode)  SourceSection(source=ensure_lines.rb [3:1 - 3:9], index=16, length=9, characters=    body1)source: (16,24) line=3 len=9 text="    body1"
| | | | tryPart  (SequenceNode)  SourceSection(source=ensure_lines.rb [3:1 - 4:9], index=16, length=19, characters=    body1\n    body2)source: (16,34) line=3 len=19 text="    body1
    body2"
| | | | | body[0]  (RubyCallNode)  SourceSection(source=ensure_lines.rb [3:1 - 3:9], index=16, length=9, characters=    body1)source: (16,24) line=3 len=9 text="    body1"
| | | | | | receiver  (SelfNode)  
| | | | | body[1]  (RubyCallNode)  SourceSection(source=ensure_lines.rb [4:1 - 4:9], index=26, length=9, characters=    body2)source: (26,34) line=4 len=9 text="    body2"
| | | | | | receiver  (SelfNode)  
| | | | ensurePart  (SequenceNode)  SourceSection(source=ensure_lines.rb [6:1 - 7:15], index=45, length=31, characters=    guaranteed1\n    guaranteed2)source: (45,75) line=6 len=31 text="    guaranteed1
    guaranteed2"
| | | | | body[0]  (RubyCallNode)  SourceSection(source=ensure_lines.rb [6:1 - 6:15], index=45, length=15, characters=    guaranteed1)source: (45,59) line=6 len=15 text="    guaranteed1"
| | | | | | receiver  (SelfNode)  
| | | | | body[1]  (RubyCallNode)  SourceSection(source=ensure_lines.rb [7:1 - 7:15], index=61, length=15, characters=    guaranteed2)source: (61,75) line=7 len=15 text="    guaranteed2"
| | | | | | receiver  (SelfNode) 

graalvmbot pushed a commit that referenced this issue Oct 10, 2022
…e translator

* So other nodes can rely on child sections being correct while in the parser.
* Fix the section of EnsureParseNode.
* Fixes #2758
* Replace setPosition() by extendPosition().
* Ensure every ParseNode has a position except NilImplicitParseNode and
  RequiredKeywordArgumentValueParseNode .
@eregon
Copy link
Member Author

eregon commented Oct 10, 2022

Fix in #2761

graalvmbot pushed a commit that referenced this issue Oct 11, 2022
…ource section for ensure (#2758)

PullRequest: truffleruby/3512
john-heinnickel pushed a commit to thermofisher-jch/truffleruby that referenced this issue Aug 16, 2023
…e translator

* So other nodes can rely on child sections being correct while in the parser.
* Fix the section of EnsureParseNode.
* Fixes oracle#2758
* Replace setPosition() by extendPosition().
* Ensure every ParseNode has a position except NilImplicitParseNode and
  RequiredKeywordArgumentValueParseNode .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant