@@ -1623,7 +1623,7 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
16231623 } else {
16241624 arg1 = compiler . compileExpression ( operands [ 1 ] , type , Constraints . ConvImplicit | Constraints . MustWrap ) ;
16251625 }
1626- let op : BinaryOp = - 1 ;
1626+ let op : BinaryOp | null = null ;
16271627 switch ( type . kind ) {
16281628 case TypeKind . I8 :
16291629 case TypeKind . I16 :
@@ -1639,14 +1639,14 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
16391639 case TypeKind . F32 : return module . binary ( BinaryOp . MaxF32 , arg0 , arg1 ) ;
16401640 case TypeKind . F64 : return module . binary ( BinaryOp . MaxF64 , arg0 , arg1 ) ;
16411641 }
1642- if ( op as i32 != - 1 ) {
1642+ if ( op ) {
16431643 let flow = compiler . currentFlow ;
16441644 let typeRef = type . toRef ( ) ;
16451645 let temp1 = flow . getTempLocal ( type ) ;
16461646 flow . setLocalFlag ( temp1 . index , LocalFlags . Wrapped ) ;
16471647 let temp2 = flow . getTempLocal ( type ) ;
16481648 flow . setLocalFlag ( temp2 . index , LocalFlags . Wrapped ) ;
1649- let ret = module . select (
1649+ return module . select (
16501650 module . local_tee ( temp1 . index , arg0 , false ) , // numeric
16511651 module . local_tee ( temp2 . index , arg1 , false ) , // numeric
16521652 module . binary ( op ,
@@ -1655,7 +1655,6 @@ function builtin_max(ctx: BuiltinFunctionContext): ExpressionRef {
16551655 ) ,
16561656 typeRef
16571657 ) ;
1658- return ret ;
16591658 }
16601659 }
16611660 compiler . error (
@@ -1691,7 +1690,7 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
16911690 } else {
16921691 arg1 = compiler . compileExpression ( operands [ 1 ] , type , Constraints . ConvImplicit | Constraints . MustWrap ) ;
16931692 }
1694- let op : BinaryOp = - 1 ;
1693+ let op : BinaryOp | null = null ;
16951694 switch ( type . kind ) {
16961695 case TypeKind . I8 :
16971696 case TypeKind . I16 :
@@ -1707,14 +1706,14 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
17071706 case TypeKind . F32 : return module . binary ( BinaryOp . MinF32 , arg0 , arg1 ) ;
17081707 case TypeKind . F64 : return module . binary ( BinaryOp . MinF64 , arg0 , arg1 ) ;
17091708 }
1710- if ( op as i32 != - 1 ) {
1709+ if ( op ) {
17111710 let flow = compiler . currentFlow ;
17121711 let typeRef = type . toRef ( ) ;
17131712 let temp1 = flow . getTempLocal ( type ) ;
17141713 flow . setLocalFlag ( temp1 . index , LocalFlags . Wrapped ) ;
17151714 let temp2 = flow . getTempLocal ( type ) ;
17161715 flow . setLocalFlag ( temp2 . index , LocalFlags . Wrapped ) ;
1717- let ret = module . select (
1716+ return module . select (
17181717 module . local_tee ( temp1 . index , arg0 , false ) , // numeric
17191718 module . local_tee ( temp2 . index , arg1 , false ) , // numeric
17201719 module . binary ( op ,
@@ -1723,7 +1722,6 @@ function builtin_min(ctx: BuiltinFunctionContext): ExpressionRef {
17231722 ) ,
17241723 typeRef
17251724 ) ;
1726- return ret ;
17271725 }
17281726 }
17291727 compiler . error (
0 commit comments