Comments (5)
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.
from v.
For my own understanding:
Why doesn't V report an error when the first branch is an int
and the other branches are i64
?
The current behavior suggests that V is silently casting the 2nd and subsequent branches to int
.
from v.
Yes. Because the first branch on Match is instructing that the return type is int not i64.
You can use: 'b' { i64(block) }
to force i64 too.
assert string_to_i64('18T')! == 18 * terra
With int:
number: 18
multiplier: 0
result: 0
With i64:
number: 18
multiplier: 1099511627776
result: 19791209299968
from v.
Yes. Because the first branch on Match is instructing that the return type is int not i64.
Why does the p
branch work?
Also, I would expect multiplier
to always be i64
. Otherwise, the other branches should be errors since they are i64
from v.
Why does the p branch work?
Ah, I defined peta wrong. bummer.
Still seems odd that match
does not issue an error in the other branches beause of assignment of an i64
to int
from v.
Related Issues (20)
- Optional explicit interface implementations HOT 12
- Allow to omit commas in multiline function signature block HOT 5
- https://vlang.io/ REPL example doesn't work HOT 1
- Provide easier installer like Rust HOT 5
- fmt: a regression was introduced in #22025 (vfmt struct init) HOT 3
- Precision format ignored in string interpolation HOT 4
- sum types should have a default 0 value for the first type mentioned in the list of types. HOT 4
- Passing a map to a generic argument changes a key value from int to an empty string HOT 1
- Module resolution depends on working directory HOT 3
- Free an optional structure HOT 7
- C error when comparing array to nil
- Compiler error when trying to convey a variadic argument set HOT 3
- Invalid conversion from camel to snake string with numbers HOT 5
- C error when returning a fixed-size array (NOTE: initialization with a for loop doesn't help) HOT 2
- C error when initializing fixed-size array HOT 2
- Returning fixed size arrays is still making C errors, even with the size being a normal int HOT 2
- C error - multiple returns values and fixed arrays
- Issue with Sokol and STBI openning images.
- cgen: Free optional string
- const name shadowing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v.