-
Notifications
You must be signed in to change notification settings - Fork 76
tag mismatch #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think I've tracked down the code that overrides the tag: compiler/source/compiler/sc3.c Lines 1783 to 1786 in ec5b746
According to a comment before that code, it's meant exactly for the cases when the array is indexed by an enum element, e.g.: enum ePlayerInfo
{
Float:pHealth
};
new player_info[MAX_PLAYERS][ePlayerInfo];
// ...
// `player_info` has tag `_:` (no tag), but the resulting tag
// is overridden with the tag from `pHealth`
player_info[playerid][pHealth] = 100.0; which makes sense, but should this rule really apply to all enum elements, including the ones that belong to anonymous enumerations? Fixing this should be trivial, we only need to add an extra check |
But you're right, anonymous enums probably shouldn't apply themselves as they weren't used to declare the original array. I can only think of very obtuse and probably wrong code that would be affected by this, and I wouldn't be against just telling people to change that code. |
No, #444 was a completely different bug (an oversight in the parsing code that made the compiler silently ignore tags in anonymous enum declarations). However, I just re-tested the stock 3.2.3664 compiler for this bug and it seems that that release is affected as well (which is strange, because I'm pretty sure there was no warning when I tested 3664 for this bug the first time). |
…ongs to a named enum Fixes pawn-lang#514.
…ongs to a named enum Fixes pawn-lang#514.
Uh oh!
There was an error while loading. Please reload this page.
Issue description:
Assigning a tagged value to an array cell indexed with an enum constant makes the compiler print warning 213 (tag mismatch), even though the array has the same tag.
Minimal complete verifiable example (MCVE):
It seems that if an array is indexed with an enum constant, the tag of the said constant somehow overrides the array tag, so in the above example the compiler expects no tag (
_:
) instead ofText:
, which doesn't seem to be correct.Originally reported by the forum user 'tnc' here: https://pro-pawn.ru/showthread.php?2207-Pawn-compiler-%283-10%29&p=96537&viewfull=1#post96537
Workspace Information:
The text was updated successfully, but these errors were encountered: