diff --git a/sourcepawn/compiler/sc2.cpp b/sourcepawn/compiler/sc2.cpp index 9dd3ca68..c660b6fb 100644 --- a/sourcepawn/compiler/sc2.cpp +++ b/sourcepawn/compiler/sc2.cpp @@ -2205,6 +2205,25 @@ int lex(cell *lexvalue,char **lexsym) tok->id = tSYMBOL; strcpy(tok->str, sc_tokens[i - tFIRST]); tok->len = strlen(tok->str); + } else if (*lptr == ':' && + (i == tINT || + i == tVOID)) + { + // Special case 'int:' to its old behavior: an implicit view_as<> cast + // with Pawn's awful lowercase coercion semantics. + const char *token = sc_tokens[i - tFIRST]; + switch (i) { + case tINT: + error(238, token, token); + break; + case tVOID: + error(239, token, token); + break; + } + lptr++; + tok->id = tLABEL; + strcpy(tok->str, token); + tok->len = strlen(tok->str); } else { tok->id = i; errorset(sRESET,0); /* reset error flag (clear the "panic mode")*/ diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 472295d1..f9b3f0e0 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -454,6 +454,8 @@ static const char *warnmsg[] = { /*235*/ "public function lacks forward declaration (symbol \"%s\")\n", /*236*/ "unknown parameter in substitution (incorrect #define pattern)\n", /*237*/ "coercing functions to and from primitives is unsupported and will be removed in the future\n", +/*238*/ "'%s:' is an illegal cast; use view_as<%s>(expression)\n", +/*239*/ "'%s' is an illegal tag; use %s as a type\n", #else "\327 \275tr\242\231\227\266 %\204\305\206a\306\210\260", "\214\343i\215 \330\371\213t/\321cro \365", diff --git a/sourcepawn/compiler/tests/ok-bad-int-cast.sp b/sourcepawn/compiler/tests/ok-bad-int-cast.sp new file mode 100644 index 00000000..d3185535 --- /dev/null +++ b/sourcepawn/compiler/tests/ok-bad-int-cast.sp @@ -0,0 +1,4 @@ +public main() +{ + new class = int:5; +}