-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Match fails oddly if branch is changed from int to i64 #21624
Comments
Yes. Because the first branch on Match is instructing that the return type is int not i64. You can use:
With int: With i64: |
Why does the Also, I would expect |
Ah, I defined peta wrong. bummer. Still seems odd that |
For my own understanding: Why doesn't V report an error when the first branch is an The current behavior suggests that V is silently casting the 2nd and subsequent branches to |
I agree. Auto promoting int to i64 is fine, since it an int fits entirely in the range of i64, but automatically casting i64 to int implicitly, should not be allowed. |
V doctor:
What did you do?
v bug_test.v
bug.v
bug_test.v
What did you expect to see?
bug_test.v should pass
What did you see instead?
Now change the second line in
bug.v
fromconst block = 512
to
const block = i64(512)
and the test passes.
This only happens with the
t
branch in the code. Other branches work: (e.g.assert string_to_164('10P')! == 10 * peta
)Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: