Skip to content

Commit ac55dd4

Browse files
committed
Turn global variable usage order warning into error
1 parent 164193c commit ac55dd4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

de.peeeq.wurstscript/src/main/java/de/peeeq/wurstscript/validation/ValidateGlobalsUsage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public void visit(ExprVarAccess e) {
6161
if (!definedVars.contains(g)
6262
&& !g.attrIsDynamicClassMember()
6363
&& g.attrNearestNamedScope() == p) {
64-
e.addWarning("Global variable " + e.getVarName() + " must be declared before it is used. " +
65-
"This will be an error in future Wurst versions.");
64+
e.addError("Global variable <" + e.getVarName() + "> must be declared before it is used.");
6665
// add variable to defined vars to silence further warnings:
6766
definedVars.add(g);
6867
}

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/BugTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void test_init_order_jass_warning() {
132132

133133
@Test
134134
public void test_init_order_globals_warning() {
135-
testAssertErrorsLines(false, "Global variable b must be declared before it is used.",
135+
testAssertErrorsLines(false, "Global variable <b> must be declared before it is used.",
136136
"package test",
137137
" integer a = b",
138138
" integer b = 3",

de.peeeq.wurstscript/src/test/java/tests/wurstscript/tests/ClassesExtTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,12 @@ public void ondestroy_dynamicdispatchFrotty1() {
391391
testAssertOkLines(true,
392392
"package test",
393393
" native testSuccess()",
394+
" string s=\"\"",
394395
" class A extends T",
395396
" class B extends T",
396397
" ondestroy",
397398
" s += \"B\"",
398399
" abstract class T",
399-
" string s=\"\"",
400400
" init",
401401
" T t = new A()",
402402
" destroy t",
@@ -411,14 +411,14 @@ public void ondestroy_dynamicdispatchFrotty2() {
411411
testAssertOkLines(true,
412412
"package test",
413413
" native testSuccess()",
414+
" string s=\"\"",
414415
" class A implements T",
415416
" class B implements T",
416417
" ondestroy",
417418
" s += \"B\"",
418419
" interface T",
419420
" function f()",
420421
" skip",
421-
" string s=\"\"",
422422
" init",
423423
" T t = new A()",
424424
" destroy t",
@@ -433,6 +433,7 @@ public void ondestroy_dynamicdispatchFrotty3() {
433433
testAssertOkLines(true,
434434
"package test",
435435
" native testSuccess()",
436+
" string s=\"\"",
436437
" abstract class C",
437438
" ondestroy",
438439
" s+=\"C\"",
@@ -443,7 +444,6 @@ public void ondestroy_dynamicdispatchFrotty3() {
443444
" interface T",
444445
" function f()",
445446
" skip",
446-
" string s=\"\"",
447447
" init",
448448
" T t = new A()",
449449
" destroy t",

0 commit comments

Comments
 (0)