You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The eq clause of an invariant type produces a function of type T * T +> bool. Therefore when two values of the type are compared, the arguments to eq are converted to type T before the equality is evaluated (like any function call).
But if one of the argument values is nil, this cannot be converted to T unless it is also an optional type. That currently causes a runtime exception; it should simply return false. For example:
types
T = nat
eq a = b == a <> b;
functions
f: [T] -> bool
f(a) == a = nil;
> p f(1)
org.overture.interpreter.runtime.ValueException: Cannot convert nil (nil) to nat
The solution is to check for a nil value before calling the eq function and return false if the underlying type is not optional.
The text was updated successfully, but these errors were encountered:
The
eq
clause of an invariant type produces a function of typeT * T +> bool
. Therefore when two values of the type are compared, the arguments toeq
are converted to type T before the equality is evaluated (like any function call).But if one of the argument values is
nil
, this cannot be converted to T unless it is also an optional type. That currently causes a runtime exception; it should simply return false. For example:The solution is to check for a nil value before calling the
eq
function and return false if the underlying type is not optional.The text was updated successfully, but these errors were encountered: