diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 07c9bea1..13485f97 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -2127,6 +2127,9 @@ static void declloc(int tokid) slength = fix_char_size(&decl); + if (fstatic && type->ident == iREFARRAY) + error(165); + if (type->ident == iARRAY || fstatic) { if (!parse_local_array_initializer(type, &cur_lit, &slength)) return; diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index e099541f..a296c84c 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -208,6 +208,7 @@ static const char *errmsg[] = { /*162*/ "cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?\n", /*163*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n", /*164*/ "allocated array type '%s' doesn't match original type '%s'\n", +/*165*/ "cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name?\n", #else "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", diff --git a/sourcepawn/compiler/tests/fail-bad-array-decls.sp b/sourcepawn/compiler/tests/fail-bad-array-decls.sp index 07d0fb0c..0a834b8f 100644 --- a/sourcepawn/compiler/tests/fail-bad-array-decls.sp +++ b/sourcepawn/compiler/tests/fail-bad-array-decls.sp @@ -5,6 +5,7 @@ public OnPluginStart() int v = 10; int invalid1[v]; int[] invalid2 = {1}; + static int[] invalid3 = {1}; } void invalid_arg1(int invalid[]) diff --git a/sourcepawn/compiler/tests/fail-bad-array-decls.txt b/sourcepawn/compiler/tests/fail-bad-array-decls.txt index 1f7022da..f415a354 100644 --- a/sourcepawn/compiler/tests/fail-bad-array-decls.txt +++ b/sourcepawn/compiler/tests/fail-bad-array-decls.txt @@ -1,6 +1,7 @@ (1) : error 162: cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name? (6) : error 161: brackets after variable name indicate a fixed-size array, but a dynamic size was given - did you mean to use 'new int[size]' syntax? (7) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given -(10) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x') -(14) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given +(8) : error 165: cannot create dynamic arrays in static scope - did you mean to create a fixed-length array with brackets after the variable name? +(11) : error 159: brackets after variable name indicate a fixed-size array, but size could not be determined - either specify sizes, an array initializer, or use dynamic syntax (such as 'char[] x') +(15) : error 160: brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given