Skip to content

Commit

Permalink
Implement initial() for arglist() (#2123)
Browse files Browse the repository at this point in the history
Co-authored-by: ike709 <[email protected]>
  • Loading branch information
ike709 and ike709 authored Dec 8, 2024
1 parent 939512d commit 8a7abfc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 0 additions & 6 deletions Content.Tests/DMProject/Broken Tests/Procs/Arglist/initial.dm

This file was deleted.

6 changes: 6 additions & 0 deletions Content.Tests/DMProject/Tests/Procs/Arglist/initial.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

/proc/_initial(...)
ASSERT(initial(arglist(args))[1] == "foo")

/proc/RunTest()
_initial("foo")
7 changes: 7 additions & 0 deletions DMCompiler/DM/Expressions/Builtins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,13 @@ public override void EmitPushValue(ExpressionContext ctx) {
return;
}

if (Expression is Arglist arglist) {
// This happens silently in BYOND
ctx.Compiler.Emit(WarningCode.PointlessBuiltinCall, Location, "calling initial() on arglist() returns the current value");
arglist.EmitPushArglist(ctx);
return;
}

ctx.Compiler.Emit(WarningCode.BadArgument, Expression.Location, $"can't get initial value of {Expression}");
ctx.Proc.Error();
}
Expand Down

0 comments on commit 8a7abfc

Please sign in to comment.