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
You need to eval each file independently. They all eval to the same z value : z: "int"
If you uncomment the other x value in the above files and comment their currently assigned one, the inverse of the type assertion works.
Here, again, run cue eval on both files separately.
What did you expect to see?
When running the (x & string) != _|_ (x is a string) type assertion with the #Artifact definition being one of the possible type, and with x being a string, I expect to enter in the if statement.
The inverse assertion (checking that the type doesn't match) however works.
myitcv
changed the title
Type assertion issue on complex definition - different behavior than with native types
internal/eval: type assertion issue on complex definition - different behavior than with native types
Jul 29, 2021
@grouville apologies for the delay in getting round to this issue.
As you will see from #943, comparison against _|_ is not well defined. And in the light of that proposal, is also not something we are likely to fix/address.
I have, however, added an explicit note to ensure we document how type assertion will work with these replacement builtins.
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
When asserting types between a native one and an open definition, the assertion doesn't work entirely
First, let's see the normal behaviors:
You need to eval each file independently. They all eval to the same
z
value :z: "int"
If you uncomment the other
x
value in the above files and comment their currently assigned one, the inverse of the type assertion works.Now, with our more complex open definition:
Here, again, run
cue eval
on both files separately.What did you expect to see?
When running the
(x & string) != _|_
(x is a string) type assertion with the#Artifact
definition being one of the possible type, and withx
being a string, I expect to enter in theif
statement.The inverse assertion (checking that the type doesn't match) however works.
What did you see instead?
The only way to make it work is by doing the inverse of the
don't match
assertion!((x & string) == _|_)
. (Works when only 2 types are involved)The text was updated successfully, but these errors were encountered: