File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -2793,15 +2793,24 @@ export class Compiler extends DiagnosticEmitter {
2793
2793
}
2794
2794
2795
2795
// Otherwise emit a normal return
2796
- return ! expr
2797
- ? isLastInBody
2798
- ? module . nop ( )
2799
- : module . return ( )
2800
- : isLastInBody
2801
- ? expr
2802
- : this . currentType == Type . void
2803
- ? module . block ( null , [ expr , module . return ( ) ] )
2804
- : module . return ( expr ) ;
2796
+ if ( expr ) {
2797
+ if ( getExpressionId ( expr ) == ExpressionId . Unreachable ) {
2798
+ // emit unreachable directly
2799
+ return expr ;
2800
+ }
2801
+ if ( isLastInBody ) {
2802
+ return expr ;
2803
+ }
2804
+ if ( this . currentType == Type . void ) {
2805
+ return module . block ( null , [ expr , module . return ( ) ] ) ;
2806
+ }
2807
+ return module . return ( expr ) ;
2808
+ } else {
2809
+ if ( isLastInBody ) {
2810
+ return module . nop ( ) ;
2811
+ }
2812
+ return module . return ( ) ;
2813
+ }
2805
2814
}
2806
2815
2807
2816
private compileSwitchStatement (
Original file line number Diff line number Diff line change @@ -658,6 +658,7 @@ class InstrumentReturns extends Pass {
658
658
var stmts = new Array < ExpressionRef > ( ) ;
659
659
if ( value ) {
660
660
let returnType = _BinaryenExpressionGetType ( value ) ;
661
+ if ( returnType != TypeRef . Unreachable ) return ;
661
662
let temp = this . parentPass . getSharedTemp ( this . currentFunction , returnType ) ;
662
663
// t = value
663
664
stmts . push (
You can’t perform that action at this time.
0 commit comments