mirror of
https://github.com/hanzoai/eslint.git
synced 2026-10-30 19:38:10 +00:00
Code Path Analysis comes to handle labels with other than loops and switches correctly. Before, it has been handling `break` statements on loop contexts and switch contexts. But now, it's handling `break` statements on independent `break` contexts.
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
/*expected
|
|
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_6->s1_7->s1_8->s1_9;
|
|
s1_1->s1_4;
|
|
s1_2->s1_9;
|
|
s1_4->s1_7;
|
|
s1_5->s1_8;
|
|
s1_9->final;
|
|
*/
|
|
|
|
A: {
|
|
B: {
|
|
if (a) {
|
|
break A;
|
|
}
|
|
if (b) {
|
|
break B;
|
|
}
|
|
foo();
|
|
}
|
|
bar();
|
|
}
|
|
|
|
baz();
|
|
|
|
/*DOT
|
|
digraph {
|
|
node[shape=box,style="rounded,filled",fillcolor=white];
|
|
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];
|
|
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];
|
|
s1_1[label="Program\nLabeledStatement\nIdentifier (A)\nBlockStatement\nLabeledStatement\nIdentifier (B)\nBlockStatement\nIfStatement\nIdentifier (a)"];
|
|
s1_2[label="BlockStatement\nBreakStatement\nIdentifier (A)"];
|
|
s1_3[style="rounded,dashed,filled",fillcolor="#FF9800",label="<<unreachable>>\nBlockStatement:exit"];
|
|
s1_4[label="IfStatement\nIdentifier (b)"];
|
|
s1_5[label="BlockStatement\nBreakStatement\nIdentifier (B)"];
|
|
s1_6[style="rounded,dashed,filled",fillcolor="#FF9800",label="<<unreachable>>\nBlockStatement:exit"];
|
|
s1_7[label="ExpressionStatement\nCallExpression\nIdentifier (foo)"];
|
|
s1_8[label="ExpressionStatement\nCallExpression\nIdentifier (bar)"];
|
|
s1_9[label="ExpressionStatement\nCallExpression\nIdentifier (baz)"];
|
|
initial->s1_1->s1_2->s1_3->s1_4->s1_5->s1_6->s1_7->s1_8->s1_9;
|
|
s1_1->s1_4;
|
|
s1_2->s1_9;
|
|
s1_4->s1_7;
|
|
s1_5->s1_8;
|
|
s1_9->final;
|
|
}
|
|
*/
|