File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1055,9 +1055,8 @@ let parse_template_constant ~start_pos ~prefix (p : Parser.t) =
10551055 match String_literal. decode_js_template_escapes txt with
10561056 | Some semantic -> Ast_helper.Const. string semantic
10571057 | None ->
1058- if p.diagnostics = [] then
1059- Parser. err ~start_pos ~end_pos: p.prev_end_pos p
1060- (Diagnostics. message " Invalid string escape sequence" );
1058+ Parser. err ~start_pos ~end_pos: p.prev_end_pos p
1059+ (Diagnostics. message " Invalid string escape sequence" );
10611060 Ast_helper.Const. string " " )
10621061 | Some _ ->
10631062 Parser. err ~start_pos ~end_pos: p.prev_end_pos p
Original file line number Diff line number Diff line change @@ -21,6 +21,19 @@ let assert_invalid_backquoted_pattern encoded =
2121 in
2222 OUnit. assert_bool " expected an invalid string escape" result.invalid
2323
24+ let assert_invalid_backquoted_pattern_after_diagnostic () =
25+ let source =
26+ {|
27+ let invalidBigint = 0x1n
28+ let f = value => switch value { | `\uD800` => 1 }
29+ | }
30+ in
31+ let result =
32+ Res_driver. parse_implementation_from_source ~for_printer: false
33+ ~display_filename: " StringLiteralTest.res" ~source
34+ in
35+ OUnit. assert_equal ~printer: string_of_int 2 (List. length result.diagnostics)
36+
2437let assert_invalid_tagged_template_pattern tag =
2538 let source =
2639 " let f = value => switch value { | " ^ tag ^ " `literal` => 1 }"
@@ -383,6 +396,8 @@ let suites =
383396 ( " backquoted patterns reject lone surrogate escapes" >:: fun _ ->
384397 assert_invalid_backquoted_pattern {|\u D800|};
385398 assert_invalid_backquoted_pattern {|\u DC00|} );
399+ ( " invalid backquoted pattern after an earlier diagnostic" >:: fun _ ->
400+ assert_invalid_backquoted_pattern_after_diagnostic () );
386401 ( " character literals retain source and semantic forms " >:: fun _ ->
387402 assert_parsed_char ~for_printer:false ~source:{|\u{61}|}
388403 ~expected_semantic:0x61;
You can’t perform that action at this time.
0 commit comments