-
-
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
C error #23403
Comments
Wow! C appart, and fixed arrays appart, I didn't know V permitted to set non-constant match options! fn check(a int, b int, c int) string {
return match a {
b { 'b' }
c { 'c' }
else { 'other' }
}
}
fn main() {
println('${check(1,1,1)}') // b
println('${check(1,0,1)}') // c
println('${check(1,0,0)}') // other
} even though in Next code is rejected but is weird: fn check_2(a int) string {
return match a {
a { 'first a' } // accepted line (but why?)
a { 'second a' } // ofending line
else { 'else' }
}
} produces:
|
Well, You In fact, you can match on ranges, on the results of fn calls, etc. - anything that matches the type of the variable you're matching against. |
This code is accepted and always prints fn check_3(a int) string {
return match a {
a { 'a' } // accepted line (but why?)
1 { '1' }
else { 'else' }
}
} |
This program can print fn check_4(a int) string {
return match a {
1 { '1' }
a { 'a' } // accepted line (but why?)
else { 'else' }
}
} |
Incorrect. It will only print fn check_4(a int) string {
return match a {
1 { '1' }
a { 'a' }
else { 'else' }
}
}
println(check_4(1))
println(check_4(2))
println(check_4(3)) output is
|
Your |
JalonSolov: For Returning to the origin of this post, seems to me the branch of fn on_event(e &gg.Event, mut app App) {
_ := match [0, 0]! {
[0, 1]! {
0
}
else {
panic('')
}
} Yes, if and only if the compiler accepts such fixed array as comparable variables. |
V version: V 0.4.9 9fc8352, press to see full `v doctor` output
What did you do?
./v -g -o vdbg cmd/v && ./vdbg main.v && main
above is the command v bug uses, but I used :
v run main.v
What did you see?
What did you expect to see?
No C error
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: