File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 1
1
use oxc_cfg:: { ControlFlowGraphBuilder , CtxCursor } ;
2
+ use oxc_syntax:: node:: AstNodeId ;
2
3
/// same as but just the skeleton
3
4
/// ```js
4
5
/// A: {
5
6
/// do {} while (a);
6
7
/// do {} while (b);
8
+ /// break A;
7
9
/// }
8
10
/// ```
9
11
#[ test]
10
- fn labeled_statement_with_multiple_loops_and_continue ( ) {
12
+ fn labeled_statement_with_multiple_loops_continue_and_break ( ) {
11
13
const A : Option < & str > = Some ( "A" ) ;
12
14
13
15
let mut cfg = ControlFlowGraphBuilder :: default ( ) ;
14
16
cfg. attach_error_harness ( oxc_cfg:: ErrorEdgeKind :: Implicit ) ;
15
17
16
18
// labeled block start
17
- let _ = cfg. new_basic_block_normal ( ) ;
18
- cfg. ctx ( A ) . default ( ) . allow_continue ( ) ;
19
+ let labeled = cfg. new_basic_block_normal ( ) ;
20
+ cfg. ctx ( A ) . default ( ) . allow_break ( ) . allow_continue ( ) ;
19
21
20
22
// loop context 1
21
23
let c1 = cfg. new_basic_block_normal ( ) ;
22
24
cfg. ctx ( None ) . default ( ) . allow_break ( ) . allow_continue ( ) ;
23
- cfg. ctx ( None ) . mark_continue ( c1) . resolve_with_upper_label ( ) ;
25
+ cfg. ctx ( None ) . mark_break ( c1 ) . mark_continue ( c1) . resolve_with_upper_label ( ) ;
24
26
25
27
// loop context 2
26
28
let c2 = cfg. new_basic_block_normal ( ) ;
27
29
cfg. ctx ( None ) . default ( ) . allow_break ( ) . allow_continue ( ) ;
28
- cfg. ctx ( None ) . mark_continue ( c2) . resolve_with_upper_label ( ) ;
30
+ cfg. ctx ( None ) . mark_break ( c2) . mark_continue ( c2) . resolve_with_upper_label ( ) ;
31
+
32
+ cfg. append_break ( AstNodeId :: dummy ( ) , A ) ;
29
33
30
34
// labeled block end
31
- cfg. ctx ( A ) . resolve ( ) ;
35
+ cfg. ctx ( A ) . mark_break ( labeled ) . resolve ( ) ;
32
36
}
You can’t perform that action at this time.
0 commit comments