Bugzilla – Bug 6380
view_as / tag conversion causes logic bug in conditional expressions
Last modified: 2015-11-04 08:04:06 PST
Created attachment 3996 [details] Test case I've hit this bug a few times and finally nailed down the cause. There's a breakdown in logic in conditional expressions related to tag conversions with view_as that causes the expression to always evaluate to true. Check out the attachment for a test case. To ways to temporarily fix this: if(view_as<int>(TFClass_Sniper) == class && true) // Put the tag conversion first. if(class == (view_as<int>(TFClass_Sniper)) && true) // Put parenthesis around the tag conversion. Using: SourcePawn Compiler 1.8.0-dev+5455. Thanks for having a look.
Commit pushed to 1.7-dev at https://github.com/alliedmodders/sourcemod https://github.com/alliedmodders/sourcemod/commit/d8eaf2f302d25fa814ada8fa13a2e2050b2ccf17 Backport change: view_as<> should require parenthesis. (bug 6380)
Sorry for not getting to this sooner. Surprisingly, this was inadvertently fixed recently on 1.8 in a change that required parenthesis in view_as<>. I have backported that fix to 1.7. It took me a while to figure out why this change fixed anything. The reason is view_as<> has the wrong precedence. It was based off the precedence level for the label operator, which is 2, invoking "hier2". But view_as<> uses precedence level 12, meaning it would dive further and find the "&&" operator at preecedence level 11. Requiring parenthesis fixed this because the parser couldn't match any new operators once it encountered the ')'. I'll fix this issue separately on both branches. Thank you for the report!
*** Bug 6379 has been marked as a duplicate of this bug. ***
Commit pushed to 1.7-dev at https://github.com/alliedmodders/sourcemod https://github.com/alliedmodders/sourcemod/commit/fe6b63c17a6babc40a8781f82146ff0afd604356 Backport: Fix view_as<> precedence. (bug 6380)
Commits pushed to clang-3.8-warnings at https://github.com/alliedmodders/sourcemod https://github.com/alliedmodders/sourcemod/commit/a1816830269acd38810e5cc306551b9c22ba9579 Fix view_as<> precedence. (bug 6380) https://github.com/alliedmodders/sourcemod/commit/5d499fe4aac3fadec8579c36e5d81d82d4fce2a9 Merge pull request #33 from alliedmodders/fix-view-as-order Fix view_as<> precedence. (bug 6380)