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

checker: properly update var info in AssignStmt

This commit is contained in:
Joe Conigliaro 2020-03-11 01:16:30 +11:00
parent 333dac4977
commit bc184a9f02

View File

@ -382,8 +382,8 @@ pub fn (c mut Checker) assign_stmt(assign_stmt mut ast.AssignStmt) {
mut scope := c.file.scope.innermost(assign_stmt.pos.pos) mut scope := c.file.scope.innermost(assign_stmt.pos.pos)
for i, _ in assign_stmt.left { for i, _ in assign_stmt.left {
mut ident := assign_stmt.left[i] mut ident := assign_stmt.left[i]
mut var_info := ident.var_info()
val_type := mr_info.types[i] val_type := mr_info.types[i]
mut var_info := ident.var_info()
var_info.typ = val_type var_info.typ = val_type
ident.info = var_info ident.info = var_info
assign_stmt.left[i] = ident assign_stmt.left[i] = ident
@ -418,12 +418,10 @@ pub fn (c mut Checker) assign_stmt(assign_stmt mut ast.AssignStmt) {
c.error('assign stmt: cannot use `$val_type_sym.name` as `$var_type_sym.name`', assign_stmt.pos) c.error('assign stmt: cannot use `$val_type_sym.name` as `$var_type_sym.name`', assign_stmt.pos)
} }
} }
else {
mut ident_var_info := ident.var_info() mut ident_var_info := ident.var_info()
ident_var_info.typ = val_type ident_var_info.typ = val_type
ident.info = ident_var_info ident.info = ident_var_info
assign_stmt.left[i] = ident assign_stmt.left[i] = ident
}
scope.override_var(ast.Var{ scope.override_var(ast.Var{
name: ident.name name: ident.name
typ: val_type typ: val_type