Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 61924f8

Browse files
committed
Handle elsif
1 parent 1bec2b4 commit 61924f8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/syntax_tree/visitor/compiler.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,17 @@ def visit_else(node)
14091409
builder.pop unless last_statement?
14101410
end
14111411

1412+
def visit_elsif(node)
1413+
visit_if(
1414+
IfNode.new(
1415+
predicate: node.predicate,
1416+
statements: node.statements,
1417+
consequent: node.consequent,
1418+
location: node.location
1419+
)
1420+
)
1421+
end
1422+
14121423
def visit_field(node)
14131424
visit(node.parent)
14141425
end

test/compiler_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ class CompilerTest < Minitest::Test
257257
"foo || bar",
258258
"if foo then bar end",
259259
"if foo then bar else baz end",
260+
"if foo then bar elsif baz then qux end",
260261
"foo if bar",
261262
"foo while bar",
262263
"for i in [1, 2, 3] do i end",

0 commit comments

Comments
 (0)