Ameba::AST::ImplicitReturnVisitor - ameba 1.7.0

# class Ameba::AST::ImplicitReturnVisitor

- Ameba::AST::ImplicitReturnVisitor
- Ameba::AST::BaseVisitor
- Crystal::Visitor
- Reference
- Object

##
Overview

AST visitor that finds nodes that are not used by their surrounding scope.

A stack is used to keep track of when a node is used, incrementing every time something will capture its implicit (or explicit) return value, such as the path in a class name or the value in an assign.

This also allows for passing through whether a node is captured from a nodes parent to its children, such as from an `if` statements parent to it's body, as the body is not used by the `if` itself, but by its parent scope.

##
Defined in:

ameba/ast/visitors/implicit_return_visitor.cr

##
Instance Method Summary

- #visit(node : Crystal::Expressions) : Bool

  The stack is swapped out here as `Crystal::Expressions` are isolated from their parents scope.

- #visit(node : Crystal::BinaryOp) : Bool
- #visit(node : Crystal::Call) : Bool
- #visit(node : Crystal::Arg) : Bool
- #visit(node : Crystal::EnumDef) : Bool
- #visit(node : Crystal::Assign | Crystal::OpAssign) : Bool
- #visit(node : Crystal::MultiAssign) : Bool
- #visit(node : Crystal::If | Crystal::Unless) : Bool
- #visit(node : Crystal::While | Crystal::Until) : Bool
- #visit(node : Crystal::Def) : Bool
- #visit(node : Crystal::Macro) : Bool
- #visit(node : Crystal::ClassDef | Crystal::ModuleDef) : Bool
- #visit(node : Crystal::FunDef) : Bool
- #visit(node : Crystal::Cast | Crystal::NilableCast | Crystal::IsA | Crystal::RespondsTo) : Bool
- #visit(node : Crystal::UnaryExpression) : Bool
- #visit(node : Crystal::TypeOf) : Bool
- #visit(node : Crystal::Annotation) : Bool
- #visit(node : Crystal::TypeDeclaration) : Bool
- #visit(node : Crystal::ArrayLiteral | Crystal::TupleLiteral) : Bool
- #visit(node : Crystal::StringInterpolation) : Bool
- #visit(node : Crystal::HashLiteral | Crystal::NamedTupleLiteral) : Bool
- #visit(node : Crystal::Case) : Bool
- #visit(node : Crystal::Select) : Bool
- #visit(node : Crystal::When) : Bool
- #visit(node : Crystal::Rescue) : Bool
- #visit(node : Crystal::ExceptionHandler) : Bool
- #visit(node : Crystal::Block) : Bool
- #visit(node : Crystal::ControlExpression) : Bool
- #visit(node : Crystal::RangeLiteral) : Bool
- #visit(node : Crystal::RegexLiteral) : Bool
- #visit(node : Crystal::Yield) : Bool
- #visit(node : Crystal::MacroExpression) : Bool
- #visit(node : Crystal::MacroIf) : Bool
- #visit(node : Crystal::MacroFor) : Bool
- #visit(node : Crystal::Alias | Crystal::TypeDef | Crystal::MacroVar)
- #visit(node : Crystal::Generic | Crystal::Path | Crystal::Union | Crystal::UninitializedVar | Crystal::OffsetOf | Crystal::LibDef | Crystal::Include | Crystal::Extend) : Bool
- #visit(node)

### Instance methods inherited from class `Ameba::AST::BaseVisitor`

visit(node : Crystal::ASTNode) visit

### Constructor methods inherited from class `Ameba::AST::BaseVisitor`

new(rule : Ameba::Rule::Base, source : Ameba::Source) new

##
Instance Method Detail

def visit(node : Crystal::Expressions) : Bool #

The stack is swapped out here as `Crystal::Expressions` are isolated from their parents scope. Only the last line in an expressions node can be captured by their parent node.

def visit(node : Crystal::BinaryOp) : Bool #
def visit(node : Crystal::Call) : Bool #
def visit(node : Crystal::Arg) : Bool #
def visit(node : Crystal::EnumDef) : Bool #
def visit(node : Crystal::Assign | Crystal::OpAssign) : Bool #
def visit(node : Crystal::MultiAssign) : Bool #
def visit(node : Crystal::If | Crystal::Unless) : Bool #
def visit(node : Crystal::While | Crystal::Until) : Bool #
def visit(node : Crystal::Def) : Bool #
def visit(node : Crystal::Macro) : Bool #
def visit(node : Crystal::ClassDef | Crystal::ModuleDef) : Bool #
def visit(node : Crystal::FunDef) : Bool #
def visit(node : Crystal::Cast | Crystal::NilableCast | Crystal::IsA | Crystal::RespondsTo) : Bool #
def visit(node : Crystal::UnaryExpression) : Bool #
def visit(node : Crystal::TypeOf) : Bool #
def visit(node : Crystal::Annotation) : Bool #
def visit(node : Crystal::TypeDeclaration) : Bool #
def visit(node : Crystal::ArrayLiteral | Crystal::TupleLiteral) : Bool #
def visit(node : Crystal::StringInterpolation) : Bool #
def visit(node : Crystal::HashLiteral | Crystal::NamedTupleLiteral) : Bool #
def visit(node : Crystal::Case) : Bool #
def visit(node : Crystal::Select) : Bool #
def visit(node : Crystal::When) : Bool #
def visit(node : Crystal::Rescue) : Bool #
def visit(node : Crystal::ExceptionHandler) : Bool #
def visit(node : Crystal::Block) : Bool #
def visit(node : Crystal::ControlExpression) : Bool #
def visit(node : Crystal::RangeLiteral) : Bool #
def visit(node : Crystal::RegexLiteral) : Bool #
def visit(node : Crystal::Yield) : Bool #
def visit(node : Crystal::MacroExpression) : Bool #
def visit(node : Crystal::MacroIf) : Bool #
def visit(node : Crystal::MacroFor) : Bool #
def visit(node : Crystal::Alias | Crystal::TypeDef | Crystal::MacroVar) #
def visit(node : Crystal::Generic | Crystal::Path | Crystal::Union | Crystal::UninitializedVar | Crystal::OffsetOf | Crystal::LibDef | Crystal::Include | Crystal::Extend) : Bool #
def visit(node) #