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
Vincenzo Palazzo 2022-03-31 22:17:43 +02:00
parent 02c80bd445
commit 01d07aba9c
No known key found for this signature in database
GPG Key ID: 8B6DC2B870B80D5F
1 changed files with 34 additions and 0 deletions

View File

@ -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> {}
}
}