Compiler exceptions
This commit is contained in:
@@ -14,6 +14,9 @@ uses
|
||||
Myc.Ast;
|
||||
|
||||
type
|
||||
// Exception specific to optimization/TCO errors
|
||||
EOptimizerException = class(EAstException);
|
||||
|
||||
IAstTCO = interface(IAstVisitor)
|
||||
function Execute(const RootNode: IAstNode): IAstNode;
|
||||
end;
|
||||
@@ -180,7 +183,6 @@ begin
|
||||
begin
|
||||
// Rebuild using factory.
|
||||
// IMPORTANT: Pass Layout AND Descriptor (TCO runs after TypeChecker).
|
||||
// (* FIX: Pass Node.IsPure to preserve it *)
|
||||
Result :=
|
||||
TAst.LambdaExpr(
|
||||
newParams,
|
||||
@@ -200,7 +202,7 @@ var
|
||||
newArgs: TArray<IAstNode>;
|
||||
begin
|
||||
if not FIsTailStack.Peek then
|
||||
raise Exception.Create('''recur'' can only be used in a tail position.');
|
||||
raise EOptimizerException.Create('''recur'' can only be used in a tail position.');
|
||||
|
||||
// Arguments are not in tail position
|
||||
FNextIsTail := False;
|
||||
@@ -254,7 +256,7 @@ begin
|
||||
Node.StaticType,
|
||||
isTailCall,
|
||||
Node.StaticTarget, // Preserve the static target from Specializer
|
||||
Node.IsTargetPure // (* FIX: Preserve the purity flag from Specializer! *)
|
||||
Node.IsTargetPure // Preserve purity flag
|
||||
);
|
||||
end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user