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

Error message for Integer type mismatch #41

Open
zilinc opened this issue Nov 28, 2016 · 12 comments
Open

Error message for Integer type mismatch #41

zilinc opened this issue Nov 28, 2016 · 12 comments

Comments

@zilinc
Copy link

zilinc commented Nov 28, 2016

Now it says something like:

Mismatch between
   U16
and
   U32
   from constraint U16 :< U32
   when checking that the expression at ("fail_large-code.cogent" (line 244, column 80))
      const_ext2Magic
   has type
      U32

Can be better.

@liamoc
Copy link
Collaborator

liamoc commented Nov 28, 2016

How can it be improved specifically?

@zilinc
Copy link
Author

zilinc commented Nov 28, 2016

Suggest using upcast maybe? The constraint U16 :< U32 is actually satisfiable.

@liamoc
Copy link
Collaborator

liamoc commented Nov 28, 2016

Ah, if you use upcast, right. OK, I can add that.

@zilinc
Copy link
Author

zilinc commented Nov 28, 2016

Oh btw, we still have functions like u16_to_u32 etc...in ext2 and bilbyfs; should use upcast instead...

@zilinc
Copy link
Author

zilinc commented Nov 28, 2016

Ummm. let a : U32 = 1 doesn't upcast.

@liamoc
Copy link
Collaborator

liamoc commented Nov 28, 2016

It shouldn't... it should infer that 1 : U32.

@zilinc
Copy link
Author

zilinc commented Nov 28, 2016

interestingly if I put 0 to a U32 field in a record, it seems ok

@liamoc
Copy link
Collaborator

liamoc commented Nov 28, 2016

The type of a numeric literal is inferred from context.. so of course that would work??

@zilinc
Copy link
Author

zilinc commented Nov 28, 2016

Ah, I might have misunderstood you. Should let a : U32 = 1 typecheck?

@liamoc
Copy link
Collaborator

liamoc commented Nov 28, 2016

Yes.

@zilinc
Copy link
Author

zilinc commented Nov 28, 2016

I see. upcast is only for variables (and constants).

@liamoc
Copy link
Collaborator

liamoc commented Nov 28, 2016

Yes, the literals are no longer given the smallest integer type possible. They are now given whatever integer type is inferred from context (so long as it's big enough to fit the literal).

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

No branches or pull requests

2 participants