File tree Expand file tree Collapse file tree 1 file changed +4
-5
lines changed
Expand file tree Collapse file tree 1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -159,17 +159,17 @@ export class CFGBuilder {
159159 switchHeadNode : string ,
160160 ) {
161161 let fallthrough : string | null = null ;
162- let previous : string | null = null ;
163- if ( ! this . flatSwitch && cases [ 0 ] ?. conditionEntry ) {
164- this . addEdge ( switchHeadNode , cases [ 0 ] . conditionEntry ) ;
165- }
162+ let previous : string | null = switchHeadNode ;
166163 cases . forEach ( ( thisCase ) => {
167164 if ( this . flatSwitch ) {
168165 if ( thisCase . consequenceEntry ) {
169166 this . addEdge ( switchHeadNode , thisCase . consequenceEntry ) ;
170167 if ( fallthrough ) {
171168 this . addEdge ( fallthrough , thisCase . consequenceEntry ) ;
172169 }
170+ if ( thisCase . isDefault ) {
171+ previous = null ;
172+ }
173173 }
174174 } else {
175175 if ( fallthrough && thisCase . consequenceEntry ) {
@@ -203,7 +203,6 @@ export class CFGBuilder {
203203 } ) ;
204204 // Connect the last node to the merge node.
205205 // No need to handle `fallthrough` here as it is not allowed for the last case.
206- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
207206 if ( previous ) {
208207 this . addEdge ( previous , mergeNode , "alternative" ) ;
209208 }
You can’t perform that action at this time.
0 commit comments