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
One way to implement this would be to simply change the narrowed types of the variables, e.g. when a is first declared as Foo { mem: 0:Int|1:Str }, we could narrow it to Foo { mem: 0:Int } or Foo { mem: 1|Str }.
For this to work we need to change how struct identities work (needed for self-referencing struct members): Currently structs are equal, if they have the same struct identity and the same template parameters.
But Foo should not be equal to the Foo where the members have been narrowed.
Naively we would compare the members for equality, but if done wrong, this leads to an infinite cycle when there is a self-referencing member.
The text was updated successfully, but these errors were encountered:
I.e. if you have a type
struct Foo { mem: Int|Str }
,then this should work:
One way to implement this would be to simply change the narrowed types of the variables, e.g. when
a
is first declared asFoo { mem: 0:Int|1:Str }
, we could narrow it toFoo { mem: 0:Int }
orFoo { mem: 1|Str }
.For this to work we need to change how struct identities work (needed for self-referencing struct members): Currently structs are equal, if they have the same struct identity and the same template parameters.
But
Foo
should not be equal to theFoo
where the members have been narrowed.Naively we would compare the members for equality, but if done wrong, this leads to an infinite cycle when there is a self-referencing member.
The text was updated successfully, but these errors were encountered: