Skip to content

Commit

Permalink
Fix out-of-order overrides (#1686)
Browse files Browse the repository at this point in the history
Co-authored-by: ike709 <[email protected]>
  • Loading branch information
wixoaGit and ike709 authored Feb 28, 2024
1 parent 59e85ec commit 62c384c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Content.Tests/DMProject/Tests/Const/Const_LateDefinition.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ var/const/late_defined_const = 1
var/a = 1 + const_var
var/const/const_var = 2

/obj/TestObj/SubType
a = 4 // Catches a regression introduced in #1550

/proc/RunTest()
var/obj/TestObj/o = new
ASSERT(o.const_var == 2)
Expand Down
3 changes: 1 addition & 2 deletions DMCompiler/DM/Builders/DMObjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ private static void ProcessVarOverride(DMObject? varObject, DMASTObjectVarOverri
variable = varObject.GetGlobalVariable(varOverride.VarName);
DMCompiler.Emit(WarningCode.StaticOverride, varOverride.Location, $"var \"{varOverride.VarName}\" cannot be overridden - it is a global var");
} else {
DMCompiler.Emit(WarningCode.ItemDoesntExist, varOverride.Location, $"var \"{varOverride.VarName}\" is not declared");
return;
throw new UnknownIdentifierException(varOverride.Location, varOverride.VarName);
}

OverrideVariableValue(varObject, ref variable, varOverride.Value);
Expand Down

0 comments on commit 62c384c

Please sign in to comment.