pawn
pawn copied to clipboard
Bad codegen with error in operator overload.
native printf(const str[], ...);
operator=(Tag:x)
{
return _:x:
}
main()
{
new a = Tag:5;
printf("%d", a);
}
This code should define a custom assignment operator for Tag:
, and call it. Instead, it gives an unused symbol warning for the operator=
and generates no code at all. Compiling with -a
gives:
CODE 0 ; 0
;program exit point
halt 0
STKSIZE 1000
Literally a totally blank AMX.
Note: This took a while to spot. I found the original bug here pawn-lang/compiler#387 and attributed it to the operator somehow, but @YashasSamaga was the one who noticed my typo, the root cause. I wrote _:x:
instead of _:x;
- a colon not a semi-colon, and very hard to spot. This should give a syntax error and not compile, but somehow messes up. I do know some errors are ignored when the function isn't used, which should be the case were it not, but it is. I think the fact that its an operator overload confuses that part of the compiler as well.