Consider previous_def implicitly accessing variables, in the same way as super does

This commit is contained in:
Sijawusz Pur Rahnama 2022-12-13 23:43:41 +01:00
parent b6f3d41211
commit bb0c0eeec6

View file

@ -19,8 +19,8 @@ module Ameba::AST
MacroFor,
}
SUPER_NODE_NAME = "super"
RECORD_NODE_NAME = "record"
SPECIAL_NODE_NAMES = %w[super previous_def]
RECORD_NODE_NAME = "record"
@scope_queue = [] of Scope
@current_scope : Scope
@ -139,7 +139,7 @@ module Ameba::AST
def visit(node : Crystal::Call)
case
when @current_scope.def?
if node.name == SUPER_NODE_NAME && node.args.empty?
if node.name.in?(SPECIAL_NODE_NAMES) && node.args.empty?
@current_scope.arguments.each do |arg|
variable = arg.variable
variable.reference(variable.node, @current_scope).explicit = false