File tree Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Expand file tree Collapse file tree 2 files changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -710,9 +710,9 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
710
710
&& context_p -> token .lit_location .type == LEXER_IDENT_LITERAL );
711
711
712
712
#if ENABLED (JERRY_ES2015 )
713
- if (context_p -> next_scanner_info_p -> source_p == context_p -> source_p )
713
+ if (context_p -> next_scanner_info_p -> source_p == context_p -> source_p
714
+ && context_p -> next_scanner_info_p -> type == SCANNER_TYPE_ERR_REDECLARED )
714
715
{
715
- JERRY_ASSERT (context_p -> next_scanner_info_p -> type == SCANNER_TYPE_ERR_REDECLARED );
716
716
parser_raise_error (context_p , PARSER_ERR_VARIABLE_REDECLARED );
717
717
}
718
718
#endif /* ENABLED (JERRY_ES2015) */
@@ -730,8 +730,6 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
730
730
status_flags |= PARSER_HAS_NON_STRICT_ARG ;
731
731
}
732
732
733
- JERRY_ASSERT (context_p -> next_scanner_info_p -> type == SCANNER_TYPE_FUNCTION );
734
-
735
733
#if ENABLED (JERRY_ES2015 )
736
734
if (is_generator_function )
737
735
{
Original file line number Diff line number Diff line change
1
+ // Copyright JS Foundation and other contributors, http://js.foundation
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ function check_syntax_error ( script )
16
+ {
17
+ try
18
+ {
19
+ eval ( script ) ;
20
+ assert ( false ) ;
21
+ }
22
+ catch ( e )
23
+ {
24
+ assert ( e instanceof SyntaxError ) ;
25
+ }
26
+ }
27
+
28
+ check_syntax_error ( 'function' )
29
+ check_syntax_error ( 'function a' )
30
+ check_syntax_error ( 'function a"' )
31
+ check_syntax_error ( 'function a"b' )
32
+ check_syntax_error ( 'function a("b' )
33
+ check_syntax_error ( 'function a(b, "c' )
34
+ check_syntax_error ( 'function a(b, c"d' )
35
+ check_syntax_error ( 'function a(b, c)"d' )
You can’t perform that action at this time.
0 commit comments