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

Commit abd7c50

Browse files
committed
Handle super with arguments
1 parent 64dd9aa commit abd7c50

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/syntax_tree/visitor/compiler.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,12 @@ 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(nil, argument_parts(node.arguments).length, VM_CALL_FCALL | VM_CALL_ARGS_SIMPLE | VM_CALL_SUPER, nil)
1548+
end
1549+
15441550
def visit_symbol_literal(node)
15451551
builder.putobject(node.accept(RubyVisitor.new))
15461552
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)