Skip to content

Commit

Permalink
Add QoL Variable#reference(scope) method
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Jan 1, 2024
1 parent 444b07c commit ce3f2b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/ameba/ast/variabling/variable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ module Ameba::AST
end
end

# :ditto:
def reference(scope : Scope)
reference(node, scope)
end

# Reference variable's assignments.
#
# ```
Expand Down
4 changes: 1 addition & 3 deletions src/ameba/ast/visitors/scope_visitor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ module Ameba::AST
when scope.type_definition? && accessor_macro?(node) then return false
when scope.def? && special_node?(node)
scope.arguments.each do |arg|
variable = arg.variable

ref = variable.reference(variable.node, scope)
ref = arg.variable.reference(scope)
ref.explicit = false
end
end
Expand Down

0 comments on commit ce3f2b7

Please sign in to comment.