File tree Expand file tree Collapse file tree 5 files changed +40
-12
lines changed Expand file tree Collapse file tree 5 files changed +40
-12
lines changed Original file line number Diff line number Diff line change @@ -2595,6 +2595,14 @@ export class Compiler extends DiagnosticEmitter {
25952595 bodyStmts . length = 1 ;
25962596 }
25972597
2598+ if ( condKind == ConditionKind . True ) {
2599+ // Body executes at least once
2600+ flow . inherit ( bodyFlow ) ;
2601+ } else {
2602+ // Otherwise executes conditionally
2603+ flow . mergeBranch ( bodyFlow ) ;
2604+ }
2605+
25982606 // Compile the incrementor if it possibly executes
25992607 let possiblyLoops = possiblyContinues || possiblyFallsThrough ;
26002608 if ( possiblyLoops ) {
@@ -2618,14 +2626,6 @@ export class Compiler extends DiagnosticEmitter {
26182626 }
26192627 }
26202628
2621- // Body executes at least once
2622- if ( condKind == ConditionKind . True ) {
2623- flow . inherit ( bodyFlow ) ;
2624-
2625- // Otherwise executes conditionally
2626- } else {
2627- flow . mergeBranch ( bodyFlow ) ;
2628- }
26292629
26302630 // Finalize
26312631 outerFlow . inherit ( flow ) ;
Original file line number Diff line number Diff line change 1010 (data $0 (i32.const 12 ) " ,\00\00\00\00\00\00\00\00\00\00\00\02\00\00\00\1c\00\00\00 i\00 s\00 s\00 u\00 e\00 s\00 /\00 2\00 8\00 2\00 5\00 .\00 t\00 s\00 " )
1111 (table $0 1 1 funcref )
1212 (elem $0 (i32.const 1 ))
13+ (export " init" (func $issues/2825/init ))
1314 (export " memory" (memory $0 ))
1415 (start $~start )
1516 (func $issues/2825/increment (param $x i32 ) (result i32 )
4950 end
5051 end
5152 )
53+ (func $issues/2825/init
54+ (local $not_unassigned i32 )
55+ loop $for-loop|0
56+ i32.const 1
57+ if
58+ i32.const 0
59+ local.set $not_unassigned
60+ local.get $not_unassigned
61+ drop
62+ br $for-loop|0
63+ end
64+ end
65+ )
5266 (func $~start
5367 call $start:issues/2825
5468 )
Original file line number Diff line number Diff line change 1- {}
1+ {}
Original file line number Diff line number Diff line change 11(module
2- (type $0 (func ( param i32 i32 i32 i32 ) ))
3- (type $1 (func ))
2+ (type $0 (func ))
3+ (type $1 (func ( param i32 i32 i32 i32 ) ))
44 (import " env" " abort" (func $~lib/builtins/abort (param i32 i32 i32 i32 )))
55 (memory $0 1 )
66 (data $0 (i32.const 1036 ) " ," )
77 (data $0.1 (i32.const 1048 ) " \02\00\00\00\1c\00\00\00 i\00 s\00 s\00 u\00 e\00 s\00 /\00 2\00 8\00 2\00 5\00 .\00 t\00 s" )
8+ (export " init" (func $issues/2825/init ))
89 (export " memory" (memory $0 ))
910 (start $~start )
11+ (func $issues/2825/init
12+ loop $for-loop|0
13+ br $for-loop|0
14+ end
15+ unreachable
16+ )
1017 (func $~start
1118 (local $0 i32 )
1219 loop $for-loop|0
Original file line number Diff line number Diff line change @@ -5,4 +5,11 @@ function increment(x: i32): i32 {
55
66for ( let i = 0 ; i < 10 ; i = increment ( i ) ) {
77 let i = 1234 ;
8- }
8+ }
9+
10+ export function init ( ) : void {
11+ let not_unassigned : i32 ;
12+ for ( ; ; not_unassigned ) {
13+ not_unassigned = 0 ;
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments