Skip to content

Commit

Permalink
ImplicitReturnVisitor visit macro defs
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodywasishere committed Jan 29, 2025
1 parent 2bbef7d commit 5c52209
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/ameba/rule/lint/unused_literal_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ module Ameba::Rule::Lint
# ^^^ error: Literal value is not used
end
%}
macro name(foo)
{% "bar" %}
# ^^^^^ error: Literal value is not used
end
CRYSTAL
end

Expand Down
13 changes: 13 additions & 0 deletions src/ameba/ast/visitors/implicit_return_visitor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ module Ameba::AST
false
end

def visit(node : Crystal::Macro) : Bool
@rule.test(@source, node, @stack.positive?)

incr_stack do
node.args.each &.accept(self)
node.double_splat.try &.accept(self)
node.block_arg.try &.accept(self)
node.body.accept(self)
end

false
end

def visit(node : Crystal::ClassDef | Crystal::ModuleDef) : Bool
@rule.test(@source, node, @stack.positive?)

Expand Down

0 comments on commit 5c52209

Please sign in to comment.