From: Igor Sysoev Date: Tue, 17 Nov 2015 14:26:27 +0000 (+0300) Subject: The first invalid token did return SyntaxError exception. X-Git-Tag: 0.1.0~125 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=49c8584208b4e21cc019062c89131888046726db;p=njs.git The first invalid token did return SyntaxError exception. Empty script now returns SyntaxError exception. --- diff --git a/njs/njs_parser.c b/njs/njs_parser.c index 1c961783..a3a48ec6 100644 --- a/njs/njs_parser.c +++ b/njs/njs_parser.c @@ -69,7 +69,13 @@ njs_parser(njs_vm_t *vm, njs_parser_t *parser) njs_parser_node_t *node, *left; token = njs_parser_token(parser); - if (nxt_slow_path(token <= NJS_TOKEN_ILLEGAL)) { + + if (nxt_slow_path(token <= NJS_TOKEN_END)) { + + if (vm->exception == NULL) { + vm->exception = &njs_exception_syntax_error; + } + return NULL; } diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 01330163..f8f41d56 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -80,13 +80,11 @@ static nxt_jscript_test_t js_test[] = { nxt_string("+1\n"), nxt_string("1") }, -#if 0 { nxt_string(""), nxt_string("SyntaxError") }, { nxt_string("\n"), nxt_string("SyntaxError") }, -#endif { nxt_string("\n +1"), nxt_string("1") },