Open nrpeterson opened 7 years ago
This does look like an error, thanks. Ifnotnull is supposed to be a convenient synonym for cast-cases (especially convenient when the number of variables you want to check is large), so their behavior should have been the same.
null
in Scala's pattern matching often has to be a special case, and the first special case, since Scala's official position is that we shouldn't be using null
(but Avro generates them). However, the real error is probably a few lines upstream of where this threw an exception, in the Java code generated by jvmcompiler.scala
for the cast-case block. It should have matched "null" by an explicit Java if
statement.
I've got the following simple file, consisting only of a type-safe cast to return a boolean for whether or not the input is non-null:
Calling this in Hadrian with null as the input throws the following exception:
If I switch it up and use the "ifnotnull" special form instead, it works just fine.
When I switch the datatype from
["null", "int"]
to ["null", "double"], it still fails. When I switch it to["null", "string"]
, the model runs... but produces the wrong output (it saystrue
).Is there an issue here of pattern matching against null?
(I should add: I have verified that null is being interpreted as null, and not as "null")