diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index c7cf1ca7..f12ac7d0 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -6965,6 +6965,28 @@ static int dofor(void) autozero=1; declloc(tok.id); /* declare local variable */ break; + case tSYMBOL: + { + // See comment in statement() near tSYMBOL. + int is_decl = FALSE; + if (matchtoken('[')) { + if (lexpeek(']')) + is_decl = TRUE; + lexpush(); + } else if (lexpeek(tSYMBOL)) { + is_decl = TRUE; + } + + if (is_decl) { + lexpush(); + nestlevel++; + autozero=1; + declloc(tSYMBOL); + break; + } + + // Fall-through to default! + } default: lexpush(); doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); /* expression 1 */ diff --git a/sourcepawn/compiler/tests/ok-for-newdecl.sp b/sourcepawn/compiler/tests/ok-for-newdecl.sp new file mode 100644 index 00000000..575151d2 --- /dev/null +++ b/sourcepawn/compiler/tests/ok-for-newdecl.sp @@ -0,0 +1,5 @@ +public OnPluginStart() +{ + for (bool x; x;) { + } +}