Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type assertions for party-collapsing types #60

Open
Zettelkasten opened this issue Nov 12, 2021 · 0 comments
Open

Type assertions for party-collapsing types #60

Zettelkasten opened this issue Nov 12, 2021 · 0 comments

Comments

@Zettelkasten
Copy link
Owner

Consider you have some partly-collapsing variable x: Ref[A]|B which through reference collapsing always acts as A|B.

Assume we want to check / assert that x actually is a Ref[A]. This is currently impossible, because in if x is Ref[A] { ... } also x acts as A|B, so this would in general by false.
The same goes for assert(x is Ref[A]).

Instead, you must check for if x is A { ... }.
This doesn't work for x: Ref[A]|A though.

A (ugly) workaround is to use the complementary check, i.e. if not(x is B) { ... }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant