Skip to content

closing/end_keyword of incomplete code changed in v1.8.0 #3851

@tompng

Description

@tompng

For Defnode of an incomplete code def f; 123, end_keyword changed from '' to '; 123' in v1.8.0.

For BlockNode of an incomplete code tap do |i|, closingchanged from '' to ' |i|'

irb(main):070> Prism.parse("def f; 123").value.statements.body[0]
=> 
@ DefNode (location: (1,0)-(1,10))
├── flags: newline
├── name: :f
├── name_loc: (1,4)-(1,5) = "f"
├── receiver: 
├── parameters: 
├── body:
   @ StatementsNode (location: (1,7)-(1,10))
   ├── flags: 
   └── body: (length: 2)
       ├── @ IntegerNode (location: (1,7)-(1,10))
          ├── flags: newline, static_literal, decimal
          └── value: 123
       └── @ MissingNode (location: (1,10)-(1,10))
           └── flags: newline
├── locals: []
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: 
├── lparen_loc: 
├── rparen_loc: 
├── equal_loc: 
└── end_keyword_loc: (1,3)-(1,10) = " f; 123" # (1,10)-(1,10) = "" in v1.7.0

Background:
I was using node.closing.empty? to check if the node has closing token in IRB's indent calculation pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions