1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ast, parser: fix reference typenode (#15346)

This commit is contained in:
yuyi 2022-08-05 08:01:49 +08:00 committed by GitHub
parent e034b35144
commit 9e50803071
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -112,8 +112,9 @@ pub type Node = CallArg
pub struct TypeNode { pub struct TypeNode {
pub: pub:
typ Type
pos token.Pos pos token.Pos
pub mut:
typ Type
} }
pub enum ComptimeTypeKind { pub enum ComptimeTypeKind {

View File

@ -607,6 +607,10 @@ fn (mut p Parser) prefix_expr() ast.Expr {
right = right.expr right = right.expr
} }
} }
if mut right is ast.TypeNode {
right.typ = right.typ.ref()
return right
}
} }
mut or_stmts := []ast.Stmt{} mut or_stmts := []ast.Stmt{}
mut or_kind := ast.OrKind.absent mut or_kind := ast.OrKind.absent

View File

@ -0,0 +1 @@
T is &u8

View File

@ -0,0 +1,10 @@
fn main() {
c := c'cstr'
proc(c)
}
fn proc<T>(input T) {
$if T is &u8 {
println('T is $T.name')
}
}