@@ -1407,14 +1407,29 @@ func (c *compiler) VisitBinaryExpr(e *ast.BinaryExpr) ast.VisitResult {
14071407 c .latestReturn = c .cbb .NewFDiv (log10_num , log10_base )
14081408 c .latestReturnType = c .ddpfloattyp
14091409 case ast .BIN_LOGIC_AND :
1410+ if lhsTyp == c .ddpinttyp || rhsTyp == c .ddpinttyp {
1411+ lhs , rhs = c .floatOrByteAsInt (lhs , lhsTyp ), c .floatOrByteAsInt (rhs , rhsTyp )
1412+ c .latestReturnType = c .ddpinttyp
1413+ } else {
1414+ c .latestReturnType = c .ddpbytetyp
1415+ }
14101416 c .latestReturn = c .cbb .NewAnd (lhs , rhs )
1411- c .latestReturnType = c .ddpinttyp
14121417 case ast .BIN_LOGIC_OR :
1418+ if lhsTyp == c .ddpinttyp || rhsTyp == c .ddpinttyp {
1419+ lhs , rhs = c .floatOrByteAsInt (lhs , lhsTyp ), c .floatOrByteAsInt (rhs , rhsTyp )
1420+ c .latestReturnType = c .ddpinttyp
1421+ } else {
1422+ c .latestReturnType = c .ddpbytetyp
1423+ }
14131424 c .latestReturn = c .cbb .NewOr (lhs , rhs )
1414- c .latestReturnType = c .ddpinttyp
14151425 case ast .BIN_LOGIC_XOR :
1426+ if lhsTyp == c .ddpinttyp || rhsTyp == c .ddpinttyp {
1427+ lhs , rhs = c .floatOrByteAsInt (lhs , lhsTyp ), c .floatOrByteAsInt (rhs , rhsTyp )
1428+ c .latestReturnType = c .ddpinttyp
1429+ } else {
1430+ c .latestReturnType = c .ddpbytetyp
1431+ }
14161432 c .latestReturn = c .cbb .NewXor (lhs , rhs )
1417- c .latestReturnType = c .ddpinttyp
14181433 case ast .BIN_MOD :
14191434 if lhsTyp == c .ddpbytetyp && rhsTyp == c .ddpbytetyp {
14201435 c .latestReturn = c .cbb .NewURem (lhs , rhs )
0 commit comments