Closed
Description
Similar to #1922 but for FlipFlop.
It's FlipFlop (FLIP2) in RubyVM::AbstractSyntaxTree
RubyVM::AbstractSyntaxTree.parse 'if (1; a..b); end'
# =>
(SCOPE@1:0-1:17
tbl: []
args: nil
body: (IF@1:0-1:17 (FLIP2@1:7-1:11 (VCALL@1:7-1:8 :a) (VCALL@1:10-1:11 :b)) (BEGIN@1:13-1:13 nil) nil))
But it's RangeNode in Prism
Prism.parse 'if (1; a..b); end'
# =>
#<Prism::ParseResult:0x00000001079465a8
@comments=[],
@errors=[],
@magic_comments=[],
@source=#<Prism::Source:0x0000000106e0c318 @offsets=[0], @source="if (1; a..b); end", @start_line=1>,
@value=
@ ProgramNode (location: (1,0)-(1,17))
├── locals: []
└── statements:
@ StatementsNode (location: (1,0)-(1,17))
└── body: (length: 1)
└── @ IfNode (location: (1,0)-(1,17))
├── if_keyword_loc: (1,0)-(1,2) = "if"
├── predicate:
│ @ ParenthesesNode (location: (1,3)-(1,12))
│ ├── body:
│ │ @ StatementsNode (location: (1,4)-(1,11))
│ │ └── body: (length: 2)
│ │ ├── @ IntegerNode (location: (1,4)-(1,5))
│ │ │ └── flags: decimal
│ │ └── @ RangeNode (location: (1,7)-(1,11))
│ │ ├── left:
│ │ │ @ CallNode (location: (1,7)-(1,8))
│ │ │ ├── receiver: ∅
│ │ │ ├── call_operator_loc: ∅
│ │ │ ├── name: :a
│ │ │ ├── message_loc: (1,7)-(1,8) = "a"
│ │ │ ├── opening_loc: ∅
│ │ │ ├── arguments: ∅
│ │ │ ├── closing_loc: ∅
│ │ │ ├── block: ∅
│ │ │ └── flags: variable_call
│ │ ├── right:
│ │ │ @ CallNode (location: (1,10)-(1,11))
│ │ │ ├── receiver: ∅
│ │ │ ├── call_operator_loc: ∅
│ │ │ ├── name: :b
│ │ │ ├── message_loc: (1,10)-(1,11) = "b"
│ │ │ ├── opening_loc: ∅
│ │ │ ├── arguments: ∅
│ │ │ ├── closing_loc: ∅
│ │ │ ├── block: ∅
│ │ │ └── flags: variable_call
│ │ ├── operator_loc: (1,8)-(1,10) = ".."
│ │ └── flags: ∅
│ ├── opening_loc: (1,3)-(1,4) = "("
│ └── closing_loc: (1,11)-(1,12) = ")"
├── then_keyword_loc: ∅
├── statements: ∅
├── consequent: ∅
└── end_keyword_loc: (1,14)-(1,17) = "end",
@warnings=[]>
Ruby 3.3dev also parses if (a if b; a..b); end
as FlipFlip. (https://bugs.ruby-lang.org/issues/19877)
RubyVM::AbstractSyntaxTree.parse 'if (a if b; a..b); end'
# =>
(SCOPE@1:0-1:22
tbl: []
args: nil
body:
(IF@1:0-1:22 (BLOCK@1:4-1:16 (IF@1:4-1:10 (VCALL@1:9-1:10 :b) (VCALL@1:4-1:5 :a) nil) (FLIP2@1:12-1:16 (VCALL@1:12-1:13 :a) (VCALL@1:15-1:16 :b)))
(BEGIN@1:18-1:18 nil) nil))