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

v2: fix if guard var type & handle blank ident in assign

This commit is contained in:
joe-conigliaro 2020-03-02 16:05:40 +11:00
parent a118c72423
commit b65fad9ca8
2 changed files with 9 additions and 2 deletions

View File

@ -153,6 +153,14 @@ pub fn (c mut Checker) infix_expr(infix_expr ast.InfixExpr) table.Type {
}
fn (c mut Checker) check_assign_expr(assign_expr ast.AssignExpr) {
match assign_expr.left {
ast.Ident {
if it.kind == .blank_ident {
return
}
}
else {}
}
left_type := c.expr(assign_expr.left)
c.expected_type = left_type
// t := c.table.get_type_symbol(left_type)

View File

@ -1161,12 +1161,11 @@ fn (p mut Parser) if_expr() ast.Expr {
is_or = true
p.open_scope()
var_name := p.check_name()
// p.table.register_var(
p.check(.decl_assign)
expr,typ := p.expr(0)
p.scope.register_var(ast.VarDecl{
name: var_name
typ: typ
expr: expr
})
cond = ast.IfGuardExpr{
var_name: var_name