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

Improve type system and type inference rules #131

Open
k-sareen opened this issue Feb 17, 2023 · 4 comments
Open

Improve type system and type inference rules #131

k-sareen opened this issue Feb 17, 2023 · 4 comments

Comments

@k-sareen
Copy link
Contributor

As discussed here: #120 (comment), the type system and inference rules should be updated to allow less verbose pattern matching for developer UX.

@titzer
Copy link
Owner

titzer commented Feb 17, 2023

Can you write a seman testcase that should pass and add to test/fail?

@k-sareen
Copy link
Contributor Author

I've been reading the type checking code in vst/Verifier.v3 and I don't understand why the ve.expr has to be null, i.e. why the match case has to be the unqualified type (see these lines).

@k-sareen
Copy link
Contributor Author

k-sareen commented Feb 20, 2023

For the error generated by test/fail/adt_type_infer03.v3 (in PR), I think the TypeSystem.isPromotable() should return true because, well A<u4>.C and A<u8>.C are the exact same type. Unless is there some internal representation issue? Even then it should just be equal, no?

EDIT: Or well, more precisely the TypeSystem.isSubtype() for variants needs updating.

@titzer
Copy link
Owner

titzer commented Feb 21, 2023

This is a subtle thing that needs to be explained better. Integer types like u4 and u8 are not related by subtyping but by promotion. That is because they could be represented differently. E.g. on a 32-bit machine a u32 will be represented by one word and u64 two words. Subtyping is only for values whose representation doesn't change when assigning a value from a subtype to a supertype location (i.e. the assignment is always pass-through, nop).

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

2 participants