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 bounds not honored at compile time #5914

Closed
trufae opened this issue Jul 21, 2020 · 4 comments · Fixed by #20641
Closed

type bounds not honored at compile time #5914

trufae opened this issue Jul 21, 2020 · 4 comments · Fixed by #20641
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.

Comments

@trufae
Copy link
Contributor

trufae commented Jul 21, 2020

V version: V 0.1.28 e1eb9c4
OS: macOS 10.15

What did you do?

Screenshot 2020-07-21 at 15 29 27

in C this generates:

byte a = ((byte)(300));

What did you expect to see?

compile time error complaining about invalid value for given type like it happens if you do a := string(123)

What did you see instead?

a is 44 :D

@trufae trufae added the Bug This tag is applied to issues which reports bugs. label Jul 21, 2020
@ntrel
Copy link
Contributor

ntrel commented Jul 21, 2020

Pretty sure this is by design. byte() is a type conversion, not a byte literal.

@ntrel
Copy link
Contributor

ntrel commented Jul 22, 2020

We could add a check that integer literals are within the bounds of the requested type conversion. byte(12) would be a de-facto byte literal.

@danieldaeschle danieldaeschle added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label Jul 21, 2021
@medvednikov
Copy link
Member

Still an issue.

@pierrec
Copy link
Contributor

pierrec commented Jan 21, 2024

I would like to work on this to improve my understanding of the compiler. However after looking around, I cannot find an entry point to fix this. Any pointer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants