Page MenuHomePhabricator

{{#switch}} should not cast values to integers or floats
Closed, DeclinedPublic

Description

{{#switch: 1.20
|1.1=a
|1.2=b
|1.10=h
|1.20=t
}}

--> b

{{#switch: 1.10
|1.1=a
|1.2=b
|1.10=h
|1.20=t
}}

--> a

I don't know when this happened, but it happened recently I think.

Details

Reference
bz46095

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:15 AM
bzimport set Reference to bz46095.
bzimport added a subscriber: Unknown Object (MLST).

Not a regression; this was probably always broken because of the use of == instead of === in the relevant parts of the code.

In fact, this is documented at https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions#Comparison_behaviour. Fixing this may break compatibility with existing wikitext.

Of course, that's not to say I like the current behavior: it can make the result depend on PHP_INT_MAX!

{{#ifeq:4000000000000000000|4000000000000000001|32-bit|64-bit}}