-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
default type of integer literals ignores type list in unions of integers #21331
Comments
The type of "3" is let x: not int8 = 3
# Error: type mismatch: got 'int literal(3)' for '3' but expected 'not int8' Maybe we can check if the type matches after the conversion from Same issue #12552 |
here's my version of this issue: proc foo(b:byte) = echo b,typeof(b)
proc write(b:byte | seq[byte]) =
echo b,typeof(b)
proc read(b:byte | seq[byte]) =
when b is seq:
for i in b:
foo(i)
else:
foo(b)
foo(3) # 3byte
## this is great ergonomics and i love it
write(3) # 3int
## this is horrible, but i'd forgive if
## this worked:
read(3) # type mismatch passing through the lit to the next function down would be very nice. ref #936 |
fixes nim-lang#4858, fixes nim-lang#10027, fixes nim-lang#12552, fixes nim-lang#15721, fixes nim-lang#21331, refs nim-lang#1214, follows up nim-lang#24216, split from nim-lang#24198
Description
i expect this code to pass, but it does not
making the type for the literal explicit fixes this
Nim Version
Nim Compiler Version 1.6.10 [Linux: amd64]
Compiled at 2022-11-21
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: f151925
active boot switches: -d:release
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
probably relevant unit tests
gives this output
The text was updated successfully, but these errors were encountered: