Fix in Recur Node declaration

This commit is contained in:
Michael Schimmel
2025-09-29 11:23:39 +02:00
parent 624af31243
commit e1a46da6f8
5 changed files with 2 additions and 13 deletions
+2 -1
View File
@@ -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;
-3
View File
@@ -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);
-2
View File
@@ -156,10 +156,8 @@ type
IRecurNode = interface(IAstNode)
{$region 'private'}
function GetArguments: TArray<IAstNode>;
function GetIsTailCall: Boolean;
{$endregion}
property Arguments: TArray<IAstNode> read GetArguments;
property IsTailCall: Boolean read GetIsTailCall;
end;
IBlockExpressionNode = interface(IAstNode)
-7
View File
@@ -157,7 +157,6 @@ type
private
FArguments: TArray<IAstNode>;
function GetArguments: TArray<IAstNode>;
function GetIsTailCall: Boolean;
public
constructor Create(const AArguments: TArray<IAstNode>);
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);