Fan

 

class

compiler::CheckErrors

sys::Obj
  compiler::CompilerSupport
    compiler::CompilerStep
      compiler::CheckErrors

CheckErrors walks the tree of statements and expressions looking for errors the compiler can detect such as invalid type usage. We attempt to leave all the error reporting to this step, so that we can batch report as many errors as possible.

Since CheckErrors already performs a full tree walk down to each leaf expression, we also do a couple of other AST decorations in this step:

1) add temp local for field assignments like return ++x
2) add temp local for returns inside protected region
3) check for field accessor optimization
4) check for field storage requirements
5) add implicit coersions: auto-casts, boxing, to non-nullable
6) implicit call to toImmutable when assigning to const field
7) mark ClosureExpr.setsConst

Slots

checkFacetSource

Void checkFacet(FacetDef f)

checkFacetsSource

Void checkFacets(FacetDef[]? facets)

checkPodDefSource

Void checkPodDef(PodDef pod)

coerceSource

Expr coerce(Expr expr, CType expected, |,| onErr)

Coerce the target expression to the specified type. If the expression is not type compatible run the onErr function.

doCoerceSource

static Expr doCoerce(Expr expr, CType expected, |,| onErr)

Coerce the target expression to the specified type. If the expression is not type compatible run the onErr function. Default Fan behavior.

enterFinallySource

override Void enterFinally(TryStmt stmt)

Callback when entering a finally block

enterStmtSource

override Void enterStmt(Stmt stmt)

Callback when entering a stmt.

enterSymbolDefSource

override Void enterSymbolDef(SymbolDef s)

Callback when entering a symbol definition.

exitFinallySource

override Void exitFinally(TryStmt stmt)

Callback when exiting a finally block

exitStmtSource

override Void exitStmt(Stmt stmt)

Callback when exiting a stmt.

isFuncAutoCoerceSource

static Bool isFuncAutoCoerce(CType actualType, CType expectedType)

isFuncAutoCoerceMatchSource

static Bool isFuncAutoCoerceMatch(CType actual, CType expected)

isRestrictedNameSource

static Bool isRestrictedName(Str name)

makeSource

new make(Compiler compiler)

needCoerceSource

static Bool needCoerce(CType from, CType to)

runSource

override Void run()

Run the step

visitExprSource

override Expr visitExpr(Expr expr)

Call to visit an expression. Return expr or a new expression if doing a replacement for the expression in the abstract syntax tree.

visitFieldDefSource

override Void visitFieldDef(FieldDef f)

Callback when visiting a field definition.

visitMethodDefSource

override Void visitMethodDef(MethodDef m)

Callback when visiting a method.

visitStmtSource

override Stmt[]? visitStmt(Stmt stmt)

Callback when visiting a stmt. Return a list to replace the statement with new statements, or return null to keep existing statement.

visitTypeDefSource

override Void visitTypeDef(TypeDef t)

Callback when visiting a type definition.