class compiler::CheckErrors

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

Source

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
canCoerce

static Bool canCoerce(Expr expr, CType expected)

Source

Return if coerce would not report a compiler error.

checkFacet

Void checkFacet(FacetDef f)

Source

checkFacets

Void checkFacets(FacetDef[]? facets)

Source

checkPodDef

Void checkPodDef(PodDef pod)

Source

coerce

static Expr coerce(Expr expr, CType expected, |->Void| onErr)

Source

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

doCoerce

static Expr doCoerce(Expr expr, CType expected, |->Void| onErr)

Source

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

enterFinally

virtual override Void enterFinally(TryStmt stmt)

Source

enterStmt

virtual override Void enterStmt(Stmt stmt)

Source

exitFinally

virtual override Void exitFinally(TryStmt stmt)

Source

exitStmt

virtual override Void exitStmt(Stmt stmt)

Source

isFuncAutoCoerce

static Bool isFuncAutoCoerce(CType actualType, CType expectedType)

Source

isFuncAutoCoerceMatch

static Bool isFuncAutoCoerceMatch(CType actual, CType expected)

Source

isRestrictedName

static Bool isRestrictedName(Str name)

Source

isSlotVisible

static Bool isSlotVisible(TypeDef curType, CSlot slot)

Source

make

new make(Compiler compiler)

Source

needCoerce

static Bool needCoerce(CType from, CType to)

Source

run

virtual override Void run()

Source

visitExpr

virtual override Expr visitExpr(Expr expr)

Source

visitFieldDef

virtual override Void visitFieldDef(FieldDef f)

Source

visitMethodDef

virtual override Void visitMethodDef(MethodDef m)

Source

visitStmt

virtual override Stmt[]? visitStmt(Stmt stmt)

Source

visitTypeDef

virtual override Void visitTypeDef(TypeDef t)

Source