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
-
Ensure the specified expression is boxed to an object reference.
-
private Void checkAssign(BinaryExpr expr)
-
private Expr? checkAssignField(FieldExpr lhs, Expr? rhs)
Check if field is assignable, return new rhs.
-
private Void checkContinue(ContinueStmt stmt)
-
private Void checkElvis(BinaryExpr expr)
- checkFacetSource
- checkFacetsSource
-
private Void checkListLiteral(ListLiteralExpr expr)
-
private Void checkLocalDef(LocalDefStmt stmt)
-
private Void checkMapLiteral(MapLiteralExpr expr)
- checkPodDefSource
-
private Void checkRangeLiteral(RangeLiteralExpr range)
-
private Void checkReturn(ReturnStmt stmt)
-
private Void checkSame(BinaryExpr expr)
-
private Void checkShortcut(ShortcutExpr shortcut)
-
private Void checkSlotLiteral(SlotLiteralExpr expr)
-
private Void checkSlotProtection(CSlot slot, Location loc, Bool setter := false)
-
private Void checkSwitch(SwitchStmt stmt)
-
private Void checkTernary(TernaryExpr expr)
-
private Void checkTypeCheck(TypeCheckExpr expr)
-
private Void checkTypeLiteral(LiteralExpr expr)
- 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.
-
private Expr coerceBoxed(Expr expr, CType expected, |,| onErr)
Run the standard coerce method and ensure the result is boxed.
- 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)
Overrides compiler::Visitor.enterFinally
Doc inherited from compiler::Visitor.enterFinally
Callback when entering a finally block
- enterStmtSource
-
override Void enterStmt(Stmt stmt)
Overrides compiler::Visitor.enterStmt
Doc inherited from compiler::Visitor.enterStmt
Callback when entering a stmt.
- enterSymbolDefSource
-
override Void enterSymbolDef(SymbolDef s)
Overrides compiler::Visitor.enterSymbolDef
Doc inherited from compiler::Visitor.enterSymbolDef
Callback when entering a symbol definition.
- exitFinallySource
-
override Void exitFinally(TryStmt stmt)
Overrides compiler::Visitor.exitFinally
Doc inherited from compiler::Visitor.exitFinally
Callback when exiting a finally block
- exitStmtSource
-
override Void exitStmt(Stmt stmt)
Overrides compiler::Visitor.exitStmt
Doc inherited from compiler::Visitor.exitStmt
Callback when exiting a stmt.
-
private Int finallyDepth := 0
-
private Expr implicitToImmutable(CType fieldType, Expr rhs, CMethod toImmutable)
- isFuncAutoCoerceSource
-
static Bool isFuncAutoCoerce(CType actualType, CType expectedType)
- isFuncAutoCoerceMatchSource
-
static Bool isFuncAutoCoerceMatch(CType actual, CType expected)
- isRestrictedNameSource
-
private Bool isSys
- makeSource
-
new make(Compiler compiler)
- needCoerceSource
-
private Int protectedRegionDepth := 0
- runSource
-
override Void run()
Overrides compiler::CompilerStep.run
Doc inherited from compiler::CompilerStep.run
Run the step
-
private Str? slotProtectionErr(CSlot slot, Bool setter := false)
- visitExprSource
-
override Expr visitExpr(Expr expr)
Overrides compiler::Visitor.visitExpr
Doc inherited from compiler::Visitor.visitExpr
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)
Overrides compiler::Visitor.visitFieldDef
Doc inherited from compiler::Visitor.visitFieldDef
Callback when visiting a field definition.
- visitMethodDefSource
-
override Void visitMethodDef(MethodDef m)
Overrides compiler::Visitor.visitMethodDef
Doc inherited from compiler::Visitor.visitMethodDef
Callback when visiting a method.
- visitStmtSource
-
override Stmt[]? visitStmt(Stmt stmt)
Overrides compiler::Visitor.visitStmt
Doc inherited from compiler::Visitor.visitStmt
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)
Overrides compiler::Visitor.visitTypeDef
Doc inherited from compiler::Visitor.visitTypeDef
Callback when visiting a type definition.