File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -4195,16 +4195,20 @@ public override LuaSyntaxNode VisitBinaryExpression(BinaryExpressionSyntax node)
41954195 var right = node . Right . AcceptExpression ( this ) ;
41964196 PopBlock ( ) ;
41974197 if ( block . Statements . Count == 0 ) {
4198- ReleaseTempIdentifier ( temp ) ;
4199- return left . Binary ( GetOperatorToken ( node . OperatorToken ) , right ) ;
4200- } else {
4201- CurBlock . AddStatement ( new LuaLocalVariableDeclaratorSyntax ( temp , left ) ) ;
4202- var ifStatement = new LuaIfStatementSyntax ( temp . EqualsEquals ( LuaIdentifierNameSyntax . Nil ) ) ;
4203- ifStatement . Body . AddStatements ( block . Statements ) ;
4204- ifStatement . Body . AddStatement ( temp . Assignment ( right ) ) ;
4205- CurBlock . AddStatement ( ifStatement ) ;
4206- return temp ;
4198+ var typeSymbol = semanticModel_ . GetTypeInfo ( node . Left ) . Type ;
4199+ bool isBool = typeSymbol != null && typeSymbol . IsBoolType ( ) ;
4200+ if ( ! isBool ) {
4201+ ReleaseTempIdentifier ( temp ) ;
4202+ return left . Binary ( GetOperatorToken ( node . OperatorToken ) , right ) ;
4203+ }
42074204 }
4205+
4206+ CurBlock . AddStatement ( new LuaLocalVariableDeclaratorSyntax ( temp , left ) ) ;
4207+ var ifStatement = new LuaIfStatementSyntax ( temp . EqualsEquals ( LuaIdentifierNameSyntax . Nil ) ) ;
4208+ ifStatement . Body . AddStatements ( block . Statements ) ;
4209+ ifStatement . Body . AddStatement ( temp . Assignment ( right ) ) ;
4210+ CurBlock . AddStatement ( ifStatement ) ;
4211+ return temp ;
42084212 }
42094213 }
42104214
You can’t perform that action at this time.
0 commit comments