-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
match []u8 gives &[]u8 #24054
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
Comments
Connected to Huly®: V_0.6-22445 |
I tested this oversimplification of your code in the playground compiles ok: type Value = string | []u8
fn bytes_to_blr(bytes []u8) {
println('${bytes}')
}
fn params_to_blr(params []Value) {
for i := 0; i < params.len; i++ {
param := params[i]
match param {
string {
bytes_to_blr(param.bytes())
}
[]u8 {
bytes_to_blr(param)
}
}
}
} I didn't check your Value sum type details nor your bytes_to_blr arguments though. |
This is because |
Since it is an interface one, use |
Is there a reason why this happens, and why does the compiler error with []u8 and not with other types? |
You are correct, this does not happen with sum types. |
Describe the bug
In the code here the compiler gives me the following error:
But the type matched []u8, why am I getting &[]u8?
Reproduction Steps
attempt to compile the linked repo
Expected Behavior
no error
Current Behavior
error
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.10 e491eb0
Environment details (OS name and version, etc.)
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: