Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement initial() for arglist() #2123

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading