]> git.kaiwu.me - njs.git/commitdiff
The first invalid token did return SyntaxError exception.
authorIgor Sysoev <igor@sysoev.ru>
Tue, 17 Nov 2015 14:26:27 +0000 (17:26 +0300)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 17 Nov 2015 14:26:27 +0000 (17:26 +0300)
Empty script now returns SyntaxError exception.

njs/njs_parser.c
njs/test/njs_unit_test.c

index 1c961783d421cd5831c722754b7c1fbd5a09601d..a3a48ec68991e1045934ca5945e2ada1bdd0e909 100644 (file)
@@ -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;
     }
 
index 0133016377bf7870c1af9e0c1f0a677bbcfcc422..f8f41d56e3553725c4eea9829a3397d684430902 100644 (file)
@@ -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") },