ncsa / qdl

the QDL programming language
Other
1 stars 0 forks source link

Make mask() use short circuit #25

Closed jjg-123 closed 1 year ago

jjg-123 commented 1 year ago

mask() should short circuit in the case that the argument is an empty stem. This is for the edge case that, since reduce always returns a scalar, it may return a null:

reduce(@||, for_each(@&&, [],[]))

Now since [] == for_each(@&&, [],[])

this means that

reduce(@||, [])

is null. Using this in mask would currently cause an error since null is not treated as a stem there. In reality, null trivially is every type, so the correct behavior is to short circuit the following case:

mask(null, [])

and return [].

jjg-123 commented 1 year ago

This is related to CIL-1736, in which a client trivially requested some scopes and the call bombed with a message about stem variables in mask. It should have found no scopes, which would have been flagged as a "missing scope exception" later and an appropriate error message would have been generated.