From 4a2728e1bf9de31108d0d7abcf58c0550f1653f0 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 8 Sep 2021 14:48:57 +0300 Subject: [PATCH] checker: verify json.decode type --- vlib/v/checker/checker.v | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index b26494084d..5d746a8d8f 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2679,7 +2679,13 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr) ast.Type { return ast.void_type } 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() c.error('json.decode: first argument needs to be a type, got `$typ`', node.pos) return ast.void_type