From 54b3c4d2c5186fad68c87cd18dc4327924c5da4b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 16 Aug 2019 18:32:32 +0300 Subject: [PATCH] json: error if the module is not imported --- compiler/parser.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/parser.v b/compiler/parser.v index 92de6254d2..fdb67b6013 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1119,9 +1119,6 @@ fn (p mut Parser) statement(add_semi bool) string { p.log('var decl') p.var_decl() } - else if p.lit == 'jsdecode' { - p.js_decode() - } else { // panic and exit count as returns since they stop the function if p.lit == 'panic' || p.lit == 'exit' { @@ -2319,6 +2316,9 @@ fn (p mut Parser) factor() string { return p.map_init() } if p.lit == 'json' && p.peek() == .dot { + if !('json' in p.table.imports) { + p.error('undefined: `json`, use `import json`') + } return p.js_decode() } //if p.fileis('orm_test') {