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

Commit a726a82

Browse files
authored
Merge pull request #210 from ruby-syntax-tree/super
Handle super with arguments
2 parents 64dd9aa + 07afc36 commit a726a82

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/syntax_tree/visitor/compiler.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,17 @@ def visit_string_literal(node)
15411541
end
15421542
end
15431543

1544+
def visit_super(node)
1545+
builder.putself
1546+
visit(node.arguments)
1547+
builder.invokesuper(
1548+
nil,
1549+
argument_parts(node.arguments).length,
1550+
VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE | VM_CALL_SUPER,
1551+
nil
1552+
)
1553+
end
1554+
15441555
def visit_symbol_literal(node)
15451556
builder.putobject(node.accept(RubyVisitor.new))
15461557
end

test/compiler_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ class CompilerTest < Minitest::Test
281281
"undef foo, bar, baz",
282282
"undef :foo, :bar, :baz",
283283
"super",
284+
"super(1)",
285+
"super(1, 2, 3)",
284286
# defined? usage
285287
"defined?(foo)",
286288
"defined?(\"foo\")",

0 commit comments

Comments
 (0)