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

checker: verify json.decode type

This commit is contained in:
Alexander Medvednikov 2021-09-08 14:48:57 +03:00
parent 55451baa03
commit 4a2728e1bf

View File

@ -2679,7 +2679,13 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr) ast.Type {
return ast.void_type return ast.void_type
} }
expr := node.args[0].expr expr := node.args[0].expr
if expr !is ast.TypeNode { if expr is ast.TypeNode {
sym := c.table.get_type_symbol(expr.typ)
if !c.table.known_type(sym.name) {
c.error('json.decode: unknown type `$sym.name`', node.pos)
}
} else {
// if expr !is ast.TypeNode {
typ := expr.type_name() typ := expr.type_name()
c.error('json.decode: first argument needs to be a type, got `$typ`', node.pos) c.error('json.decode: first argument needs to be a type, got `$typ`', node.pos)
return ast.void_type return ast.void_type