-
-
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
(Compile-Time) C error: cannot convert 'struct array' to 'int' #15232
Comments
comptime
error: cannot convert 'struct array' to 'int' (C error)
V should give a better error message here, but the problem is in your code. You're passing a slice (which is basically an array) to a method that only takes a single |
I thought it should compile because (for some reason) this haves the same workaround as #15230 🤔
This compiles without problem: import os
struct Dummy {}
fn (d Dummy) sample(x int) int {
return x + 1
}
fn main() {
$for method in Dummy.methods {
tmp := os.args[1..]
println(Dummy{}.$method(tmp))
}
} And it doesn't even fail nor panics at runtime with more or less than one element in |
I don't know if this [passing arrays to methods at compile-time this way] is a feature or a bug but it's really cool. It doesn't work at all with float types tho 😢 (#15220) |
V Doctor:
What did you do?
What did you expect to see?
v run bug_comptime1.v 5
:6 # (Console Output)
What did you see instead?
v -cg bug_comptime1.v
v -prod -cg bug_comptime1.v
The text was updated successfully, but these errors were encountered: