Advertisement

Bug in compiler

Started by May 10, 2012 12:29 PM
3 comments, last by virious 12 years, 6 months ago
Hi, I think I've found a bug in a compiler. For the reproduction of this behaviour, use asrun sample, but modify the script in the script.as so the enum E looks similar to this one:

enum E
{
VALUE1 = 20somegarbage,
VALUE2 = 30moregarbage
}


The application will compile and run without any error. But it should throw some "bad suffix on number" error information.
I think that the problem is in as_tokenizer.cpp in method:

bool asCTokenizer::IsConstant(const char *source, size_t sourceLength, size_t &tokenLength, eTokenType &tokenType) const

which identifies "20somegarbage" and "30moregarbage" as ttIntConstant. In this loop:


size_t n;
for( n = 0; n < sourceLength; n++ )
{
if( source[n] < '0' || source[n] > '9' )
break;
}


it only goes to first unallowed char (in this case "s" for the VALUE1) and does nothing about the fact that 20somegarbage is not a proper constant identifier here.

For this test I'm using HEAD revision (currently 1301), but this error is present in earlier versions of the AngelScript library.

Thanks in advance!
Yes, you're correct. I'll have this fixed.

Thanks for the detailed analysis on the problem.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
Thank you :). You're welcome :).
I've fixed this bug in revision 1303.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks!

This topic is closed to new replies.

Advertisement