Skip to content

Commit 0657be8

Browse files
add global variable name check with other globals
1 parent 12ce440 commit 0657be8

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

Code/ScriptSystem/Script.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ public static void CheckForVariableNameCollisions(Variable newVariable, IEnumera
368368
.Any(gv => Variable.AreSyntacticallySame(gv, newVariable)))
369369
{
370370
throw new CustomScriptRuntimeError(
371-
$"Tried to create a local variable '{newVariable}', " +
372-
$"but there is already a global variable with the same name."
371+
$"Tried to create a variable '{newVariable}', " +
372+
$"but there already exists a variable with the same name."
373373
);
374374
}
375375
}

Code/VariableSystem/VariableIndex.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public static void Initialize()
7777

7878
public static void AddGlobalVariable(Variable variable)
7979
{
80+
Script.CheckForVariableNameCollisions(variable, GlobalVariables);
8081
foreach (var runningScript in Script.RunningScripts)
8182
{
8283
Script.CheckForVariableNameCollisions(variable, runningScript.LocalVariables);

0 commit comments

Comments
 (0)