checker: fixes cast comparison between generics
This PR introduce the error in the cast comparison when generics are used.
This is an example of stacktrace
```
➜ v git:(macros/generic_cast) ✗ ./v vlib/v/checker/tests/generic_cast_complex_interface.vv
vlib/v/checker/tests/generic_cast_complex_interface.vv:29:10: error: cannot cast `Some<ParseRes>` to `Token, ParseErr>`
27 | match r {
28 | Some<ParseRes> {
29 | rx := Result<[]Token, ParseErr>(r)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
30 | println(rx)
31 | }
```
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
pull/13887/head
parent
02c80bd445
commit
01d07aba9c
|
|
@ -0,0 +1,34 @@
|
||||||
|
type ParseRes = Result<[]Token, ParseErr>
|
||||||
|
|
||||||
|
struct ParseErr{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type Opt<T> = None<T> | Some<T>
|
||||||
|
|
||||||
|
struct None<T> {}
|
||||||
|
|
||||||
|
struct Some<T> {
|
||||||
|
value T
|
||||||
|
}
|
||||||
|
|
||||||
|
type Result<T, U> = Err<U> | Ok<T>
|
||||||
|
|
||||||
|
struct Ok<T> {
|
||||||
|
value T
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Err<U> {
|
||||||
|
value U
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
r := Opt<ParseRes>(None<ParseRes>{})
|
||||||
|
match r {
|
||||||
|
Some<ParseRes> {
|
||||||
|
rx := Result<[]Token, ParseErr>(r)
|
||||||
|
println(rx)
|
||||||
|
}
|
||||||
|
None<ParseRes> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue