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

all: if-is smartcast part 1 (#5730)

This commit is contained in:
Daniel Däschle
2020-07-08 15:17:28 +02:00
committed by GitHub
parent 3b0dfd9ae1
commit b62bf59c21
6 changed files with 58 additions and 14 deletions

View File

@ -425,10 +425,10 @@ pub mut:
pub struct IfExpr {
pub:
tok_kind token.Kind
branches []IfBranch
left Expr // `a` in `a := if ...`
pos token.Position
pub mut:
branches []IfBranch
is_expr bool
typ table.Type
has_else bool
@ -439,7 +439,10 @@ pub:
cond Expr
stmts []Stmt
pos token.Position
body_pos token.Position
comments []Comment
pub mut:
smartcast bool // should only be true if cond is `x is sumtype`, it will be set in checker - if_expr
}
pub struct LockExpr {

View File

@ -286,7 +286,7 @@ pub fn (node Stmt) str() string {
}
}
out += left.str()
if i < it.left.len - 1 {
if i < node.left.len - 1 {
out += ','
}
}