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

Daimona created this task.Mar 21 2019, 3:04 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 21 2019, 3:04 PM

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

Daimona claimed this task.Mar 21 2019, 3:51 PM
Daimona updated the task description. (Show Details)Mar 23 2019, 7:35 PM

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

Daimona closed this task as Resolved.Jul 5 2019, 7:10 AM