-
Notifications
You must be signed in to change notification settings - Fork 174
Open
Description
This invalid syntax is parsed correctly, but makes the "this leaks out" part leak out of the AssocNode, HashPatternNode and even MatchPredicateNode, making it act as if it were a statement on a new line.
x in { "interpolated #{123} symbol}": "this leaks out" }This happens in any pattern context (case/in, =>, and in)
This is pretty hard to gracefully recover from, because we need to look at siblings to pattern constructs, and not just within those constructs themselves.
r = Prism.parse 'x in { "interpolated #{123} symbol}": "this leaks out" }'
r.value.statements
=>
@ StatementsNode (location: (1,0)-(1,56))
├── flags: ∅
└── body: (length: 3)
├── @ MatchPredicateNode (location: (1,0)-(1,39))
│ ├── flags: newline
│ ├── value:
│ │ @ NilNode (location: (1,0)-(1,3))
│ │ └── flags: static_literal
│ ├── pattern:
│ │ @ HashPatternNode (location: (1,7)-(1,39))
│ │ ├── flags: ∅
│ │ ├── constant: ∅
│ │ ├── elements: (length: 1)
│ │ │ └── @ AssocNode (location: (1,9)-(1,39))
│ │ │ ├── flags: ∅
│ │ │ ├── key:
│ │ │ │ @ InterpolatedSymbolNode (location: (1,9)-(1,39))
│ │ │ │ ├── flags: ∅
│ │ │ │ ├── opening_loc: (1,9)-(1,10) = "\""
│ │ │ │ ├── parts: (length: 3)
│ │ │ │ │ ├── @ StringNode (location: (1,10)-(1,23))
│ │ │ │ │ │ ├── flags: static_literal, frozen
│ │ │ │ │ │ ├── opening_loc: ∅
│ │ │ │ │ │ ├── content_loc: (1,10)-(1,23) = "interpolated "
│ │ │ │ │ │ ├── closing_loc: ∅
│ │ │ │ │ │ └── unescaped: "interpolated "
│ │ │ │ │ ├── @ EmbeddedStatementsNode (location: (1,23)-(1,29))
│ │ │ │ │ │ ├── flags: ∅
│ │ │ │ │ │ ├── opening_loc: (1,23)-(1,25) = "\#{"
│ │ │ │ │ │ ├── statements:
│ │ │ │ │ │ │ @ StatementsNode (location: (1,25)-(1,28))
│ │ │ │ │ │ │ ├── flags: ∅
│ │ │ │ │ │ │ └── body: (length: 1)
│ │ │ │ │ │ │ └── @ IntegerNode (location: (1,25)-(1,28))
│ │ │ │ │ │ │ ├── flags: static_literal, decimal
│ │ │ │ │ │ │ └── value: 123
│ │ │ │ │ │ └── closing_loc: (1,28)-(1,29) = "}"
│ │ │ │ │ └── @ StringNode (location: (1,29)-(1,37))
│ │ │ │ │ ├── flags: static_literal, frozen
│ │ │ │ │ ├── opening_loc: ∅
│ │ │ │ │ ├── content_loc: (1,29)-(1,37) = " symbol}"
│ │ │ │ │ ├── closing_loc: ∅
│ │ │ │ │ └── unescaped: " symbol}"
│ │ │ │ └── closing_loc: (1,37)-(1,39) = "\":"
│ │ │ ├── value:
│ │ │ │ @ MissingNode (location: (1,9)-(1,39))
│ │ │ │ └── flags: ∅
│ │ │ └── operator_loc: ∅
│ │ ├── rest: ∅
│ │ ├── opening_loc: (1,7)-(1,8) = "{"
│ │ └── closing_loc: (1,39)-(1,39) = ""
│ └── operator_loc: (1,4)-(1,6) = "in"
├── @ StringNode (location: (1,40)-(1,56))
│ ├── flags: newline
│ ├── opening_loc: (1,40)-(1,41) = "\""
│ ├── content_loc: (1,41)-(1,55) = "this leaks out"
│ ├── closing_loc: (1,55)-(1,56) = "\""
│ └── unescaped: "this leaks out"
└── @ MissingNode (location: (1,56)-(1,56))
└── flags: newline
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels