From e1a46da6f8e47216372336e08a18f372a7d07396 Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Mon, 29 Sep 2025 11:23:39 +0200 Subject: [PATCH] Fix in Recur Node declaration --- .../{FullApiToClipboard.bat => ASTApiToClipboard.bat} | 0 Src/AST/Myc.Ast.Dumper.pas | 3 ++- Src/AST/Myc.Ast.Evaluator.pas | 3 --- Src/AST/Myc.Ast.Nodes.pas | 2 -- Src/AST/Myc.Ast.pas | 7 ------- 5 files changed, 2 insertions(+), 13 deletions(-) rename IntfExtract/{FullApiToClipboard.bat => ASTApiToClipboard.bat} (100%) diff --git a/IntfExtract/FullApiToClipboard.bat b/IntfExtract/ASTApiToClipboard.bat similarity index 100% rename from IntfExtract/FullApiToClipboard.bat rename to IntfExtract/ASTApiToClipboard.bat diff --git a/Src/AST/Myc.Ast.Dumper.pas b/Src/AST/Myc.Ast.Dumper.pas index db3e5a4..6052401 100644 --- a/Src/AST/Myc.Ast.Dumper.pas +++ b/Src/AST/Myc.Ast.Dumper.pas @@ -269,7 +269,8 @@ function TAstDumper.VisitRecurNode(const Node: IRecurNode): TDataValue; var arg: IAstNode; begin - LogFmt('Recur (IsTailCall: %s)', [Node.IsTailCall.ToString(TUseBoolStrs.True)]); + // 'recur' must be a tail call, which is enforced by the binder. + Log('Recur'); Indent; LogFmt('Arguments (%d):', [Length(Node.Arguments)]); Indent; diff --git a/Src/AST/Myc.Ast.Evaluator.pas b/Src/AST/Myc.Ast.Evaluator.pas index e84a023..9e24580 100644 --- a/Src/AST/Myc.Ast.Evaluator.pas +++ b/Src/AST/Myc.Ast.Evaluator.pas @@ -269,9 +269,6 @@ var i: Integer; begin // The binder ensures this is only in a tail position. - if not Node.IsTailCall then - raise EInvalidOperation.Create('Recur has to be a tail call'); - SetLength(argValues, Length(Node.Arguments)); for i := 0 to High(Node.Arguments) do argValues[i] := Node.Arguments[i].Accept(Self); diff --git a/Src/AST/Myc.Ast.Nodes.pas b/Src/AST/Myc.Ast.Nodes.pas index ac14a84..022cce0 100644 --- a/Src/AST/Myc.Ast.Nodes.pas +++ b/Src/AST/Myc.Ast.Nodes.pas @@ -156,10 +156,8 @@ type IRecurNode = interface(IAstNode) {$region 'private'} function GetArguments: TArray; - function GetIsTailCall: Boolean; {$endregion} property Arguments: TArray read GetArguments; - property IsTailCall: Boolean read GetIsTailCall; end; IBlockExpressionNode = interface(IAstNode) diff --git a/Src/AST/Myc.Ast.pas b/Src/AST/Myc.Ast.pas index 9b04b43..d0933dd 100644 --- a/Src/AST/Myc.Ast.pas +++ b/Src/AST/Myc.Ast.pas @@ -157,7 +157,6 @@ type private FArguments: TArray; function GetArguments: TArray; - function GetIsTailCall: Boolean; public constructor Create(const AArguments: TArray); function Accept(const Visitor: IAstVisitor): TDataValue; override; @@ -472,12 +471,6 @@ begin Result := FArguments; end; -function TRecurNode.GetIsTailCall: Boolean; -begin - // 'recur' is always a tail call by definition. - Result := True; -end; - { TBlockExpressionNode } constructor TBlockExpressionNode.Create(const AExpressions: array of IAstNode);