From: Dmitry Volyntsev Date: Tue, 23 Apr 2019 12:31:40 +0000 (+0300) Subject: Fixed condition on already been declared exception. X-Git-Tag: 0.3.2~54 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=6ce4be7c9311ff4a133980c5823a9909fac69895;p=njs.git Fixed condition on already been declared exception. --- diff --git a/njs/njs_parser.c b/njs/njs_parser.c index cef217d8..54b6c16d 100644 --- a/njs/njs_parser.c +++ b/njs/njs_parser.c @@ -203,7 +203,6 @@ njs_parser_scope_begin(njs_vm_t *vm, njs_parser_t *parser, njs_scope_t type) } else { if (type == NJS_SCOPE_GLOBAL) { type += NJS_INDEX_GLOBAL_OFFSET; - scope->module = vm->options.module; } scope->next_index[0] = type; diff --git a/njs/njs_variable.c b/njs/njs_variable.c index 7b5f38b7..ae8b15b1 100644 --- a/njs/njs_variable.c +++ b/njs/njs_variable.c @@ -91,17 +91,17 @@ njs_variable_scope_add(njs_vm_t *vm, njs_parser_scope_t *scope, if (nxt_lvlhsh_find(&scope->variables, lhq) == NXT_OK) { var = lhq->value; - if (!scope->module && scope->type != NJS_SCOPE_BLOCK) { - return var; - } - - if (type == NJS_VARIABLE_FUNCTION - || var->type == NJS_VARIABLE_FUNCTION) + if (scope->module || scope->type == NJS_SCOPE_BLOCK + || (scope->type == NJS_SCOPE_GLOBAL && vm->options.module)) { - njs_parser_syntax_error(vm, vm->parser, - "\"%V\" has already been declared", - &lhq->key); - return NULL; + if (type == NJS_VARIABLE_FUNCTION + || var->type == NJS_VARIABLE_FUNCTION) + { + njs_parser_syntax_error(vm, vm->parser, + "\"%V\" has already been declared", + &lhq->key); + return NULL; + } } return var;