vfmt: fix segfault in update where the struct is not yet known

pull/5555/head
Delyan Angelov 2020-06-28 14:07:28 +03:00
parent 0661273aad
commit fa867578bc
1 changed files with 5 additions and 2 deletions

View File

@ -150,8 +150,11 @@ fn (mut p Parser) sql_stmt() ast.SqlStmt {
// fields := info.fields.filter(it.typ in [table.string_type, table.int_type, table.bool_type])
table_name = sym.name
} else if kind == .update {
idx := p.table.find_type_idx(table_name)
table_type = table.new_type(idx)
if !p.pref.is_fmt {
// NB: in vfmt mode, v parses just a single file and table_name may not have been registered
idx := p.table.find_type_idx(table_name)
table_type = table.new_type(idx)
}
p.check_sql_keyword('where')
where_expr = p.expr(0)
}