Page MenuHomePhabricator

Z802/if treats an instance of a Typed list, a Typed pair, a Typed map or Void as False, rather than as non-Boolean
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
Z42/False is returned from the Z802K3/else branch (as specified in the calls).

What should have happened instead?:
Z506/Argument type mismatch error, because in each case the condition does not evaluate to a Boolean result.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):
Non-generic Types generally seem to work as expected, as do Typed list, Typed pair and Typed map as a Type.

Although instances of a custom type or Wikidata enumeration type correctly fail with a Z506 error, the actual type is not reported, unlike the types themselves, which are correctly identified as "Z4". Booleans don’t fail, of course, but Strings do, and here the argument itself is reported with no Type. With Z11/Monolingual text, the Type is reported but not the value. It’s not obvious to me why the Type and value should not be reported in all cases, subject to any limits on the message size.

Event Timeline

Jdforrester-WMF subscribed.

Yes, we've removed a great deal of the validation in the system for performance reasons, and this is one of those cases. We could adjust the built-in code to check this anyway (which obviates the point of a typed system, but oh well), but what's the worry about this behaviour?

Yes, we've removed a great deal of the validation in the system for performance reasons, and this is one of those cases. We could adjust the built-in code to check this anyway (which obviates the point of a typed system, but oh well), but what's the worry about this behaviour?

The fact that I’ve not stumbled across this before may provide some reassurance, but it seems that Validate boolean (Z140) also returns these types of object as “valid” Booleans.

A practical consequence appears in iffy, Composition (Try-Catch) (Z30090), where an extra guard is needed on the False path to let Z15733 pass. That makes « iffy False returns “no” (Z30117) » noticeably slower than « iffy True returns “yes” (Z15730). This is just an example rather than an important function in its own right.