Fixed parsing case/default in an unclosed function block in switch.
diff --git a/src/njs_parser.c b/src/njs_parser.c
index aaa99b6..aef1ffe 100644
--- a/src/njs_parser.c
+++ b/src/njs_parser.c
@@ -4713,7 +4713,10 @@
     if (parser->ret != NJS_OK) {
         if (token->type != NJS_TOKEN_CLOSE_BRACE) {
             parser->node = parser->target;
-            return njs_parser_stack_pop(parser);
+
+            (void) njs_parser_stack_pop(parser);
+
+            return parser->ret;
         }
 
         return njs_parser_failed(parser);
@@ -6098,6 +6101,10 @@
 {
     parser->target->right->right = parser->node;
 
+    if (parser->ret != NJS_OK && parser->target->scope != parser->scope) {
+        return njs_parser_failed(parser);
+    }
+
     njs_parser_next(parser, njs_parser_switch_case);
 
     return NJS_OK;
@@ -6153,6 +6160,10 @@
         parser->target->right = parser->node;
     }
 
+    if (parser->ret != NJS_OK && parser->target->scope != parser->scope) {
+        return njs_parser_failed(parser);
+    }
+
     njs_parser_next(parser, njs_parser_switch_case_wo_def);
 
     return NJS_OK;
diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c
index d003da7..529eea7 100644
--- a/src/test/njs_unit_test.c
+++ b/src/test/njs_unit_test.c
@@ -2958,6 +2958,24 @@
               "map((v)=>{switch(v) { case isNaN: return 1; default: return 0;}})"),
       njs_str("1,0,0") },
 
+    { njs_str("switch (1) {case 1: ii > 1; ii => default:}"),
+      njs_str("SyntaxError: Unexpected token \"default\" in 1") },
+
+    { njs_str("switch (1) {case 1: ii > 1; var a = functin () {default:}"),
+      njs_str("SyntaxError: Unexpected token \"{\" in 1") },
+
+    { njs_str("switch (1) {default: ii > 1; ii => case 2:}"),
+      njs_str("SyntaxError: Unexpected token \"case\" in 1") },
+
+    { njs_str("switch (1) {default: ii > 1; var a = functin () {case 2:}"),
+      njs_str("SyntaxError: Unexpected token \"{\" in 1") },
+
+    { njs_str("switch (1) {case 1: ii > 1; ii => case 2:}"),
+      njs_str("SyntaxError: Unexpected token \"case\" in 1") },
+
+    { njs_str("switch (1) {case 1: ii > 1; var a = functin () {case 2:}"),
+      njs_str("SyntaxError: Unexpected token \"{\" in 1") },
+
     /* continue. */
 
     { njs_str("continue"),