Allow exponentials with signed base and unsigned power.

This commit is contained in:
krk
2019-09-04 17:32:47 +02:00
committed by chriseth
parent c499758cd8
commit 33f7f960cf
10 changed files with 72 additions and 18 deletions
@@ -1,3 +1,3 @@
contract test { function() external { uint x = 3; int y = -4; x ** y; } }
// ----
// TypeError: (62-68): Operator ** not compatible with types uint256 and int256
// TypeError: (62-68): Operator ** not compatible with types uint256 and int256. Exponentiation power is not allowed to be a signed integer type.
@@ -1,3 +1,5 @@
contract test { function() external { uint x = 3; int y = -4; y ** x; } }
// ----
// TypeError: (62-68): Operator ** not compatible with types int256 and uint256
contract test {
function() external { uint x = 3; int y = -4; y ** x; }
function f() public pure { int16 x = 3; uint8 y = 4; x ** y; }
function g() public pure { int16 x = 3; uint16 y = 4; x ** y; }
}
@@ -1,9 +1,8 @@
contract test {
function f() public { int x = 3; int y = 4; x ** y; }
function g() public { int16 x = 3; uint8 y = 4; x ** y; }
function h() public { uint8 x = 3; int16 y = 4; x ** y; }
}
// ----
// TypeError: (64-70): Operator ** not compatible with types int256 and int256. Exponentiation is not allowed for signed integer types.
// TypeError: (126-132): Operator ** not compatible with types int16 and uint8. Exponentiation is not allowed for signed integer types.
// TypeError: (188-194): Operator ** not compatible with types uint8 and int16. Exponentiation is not allowed for signed integer types.
// TypeError: (64-70): Operator ** not compatible with types int256 and int256. Exponentiation power is not allowed to be a signed integer type.
// TypeError: (126-132): Operator ** not compatible with types uint8 and int16. Exponentiation power is not allowed to be a signed integer type.
// Warning: (126-132): The result type of the exponentiation operation is equal to the type of the first operand (uint8) ignoring the (larger) type of the second operand (int16) which might be unexpected. Silence this warning by either converting the first or the second operand to the type of the other.