File tree 5 files changed +40
-12
lines changed
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 {
2595
2595
bodyStmts . length = 1 ;
2596
2596
}
2597
2597
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
+
2598
2606
// Compile the incrementor if it possibly executes
2599
2607
let possiblyLoops = possiblyContinues || possiblyFallsThrough ;
2600
2608
if ( possiblyLoops ) {
@@ -2618,14 +2626,6 @@ export class Compiler extends DiagnosticEmitter {
2618
2626
}
2619
2627
}
2620
2628
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
- }
2629
2629
2630
2630
// Finalize
2631
2631
outerFlow . inherit ( flow ) ;
Original file line number Diff line number Diff line change 10
10
(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 " )
11
11
(table $0 1 1 funcref )
12
12
(elem $0 (i32.const 1 ))
13
+ (export " init" (func $issues/2825/init ))
13
14
(export " memory" (memory $0 ))
14
15
(start $~start )
15
16
(func $issues/2825/increment (param $x i32 ) (result i32 )
49
50
end
50
51
end
51
52
)
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
+ )
52
66
(func $~start
53
67
call $start:issues/2825
54
68
)
Original file line number Diff line number Diff line change 1
- {}
1
+ {}
Original file line number Diff line number Diff line change 1
1
(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 ) ))
4
4
(import " env" " abort" (func $~lib/builtins/abort (param i32 i32 i32 i32 )))
5
5
(memory $0 1 )
6
6
(data $0 (i32.const 1036 ) " ," )
7
7
(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 ))
8
9
(export " memory" (memory $0 ))
9
10
(start $~start )
11
+ (func $issues/2825/init
12
+ loop $for-loop|0
13
+ br $for-loop|0
14
+ end
15
+ unreachable
16
+ )
10
17
(func $~start
11
18
(local $0 i32 )
12
19
loop $for-loop|0
Original file line number Diff line number Diff line change @@ -5,4 +5,11 @@ function increment(x: i32): i32 {
5
5
6
6
for ( let i = 0 ; i < 10 ; i = increment ( i ) ) {
7
7
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