Page MenuHomePhabricator

Short-circuit evaluation fails with multiple comparisons
Closed, ResolvedPublic


After T214674 for assignments and T214642 for consecutive operations, I found another shortcircuit bug happening with consecutive comparisons. So, for instance, this code

-10 < something < 10

will pass the syntax check but will fail the actual parsing (since -10 < something is always lesser than 10 and the shortcircuit will trigger). However, contrary to what we did for T214642 (where we fixed short-circuit itself), we should ban this syntax altogether. Firstly for consistency with PHP, second because this doesn't do what users think it would do: the above evaluates to ( -10 < something ) < 10, which is true|false < 10, and not to -10 < something & something < 10.

There's no need to follow a deprecation plan, as I said above this already breaks filters.

Event Timeline

Change 498127 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Disallow consecutive comparisons

Change 498127 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Disallow consecutive comparisons