V version:
V 0.1.29 cbcba2e
OS:
64-bit Arch Linux, up-to-date
What did you do?
type Foo = int | string
fn main () {
mut bar := Foo(5)
match bar {
int {println("it's an int: $bar")}
string {println("shouldn't happen")}
}
bar = Foo('hello')
match bar {
string {println("it's a string: "+bar)}
int {println("shouldn't happen")}
}
}
What did you expect to see?
An executable that, when run, prints
It's an int: 5
It's a string: hello
What did you see instead?
The following from the compiler:
dca@franz:~/Software/v_issues$ ../v/v main.v
main.v:10:42: error: mismatched types `string` and `string`
8 | bar = Foo('hello')
9 | match bar {
10 | string {println("it's a string: "+bar)}
| ^
11 | int {println("shouldn't happen")}
12 | }
dca@franz:~/Software/v_issues$
This works. It first references and then deferences it but it shouldn't be the case
type Foo = int | string
fn main () {
mut bar := Foo(5)
match bar {
int {println("it's an int: $bar")}
string {println("shouldn't happen")}
}
bar = Foo('hello')
match bar {
string {println("it's a string: "+ *(&bar))}
int {println("shouldn't happen")}
}
}
Fixed by #6342
Please re-open if the issue is still valid 馃檪
Most helpful comment
Fixed by #6342