mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add tests for implcit conversions from literals to fixed-point numbers.
This commit is contained in:
+2
-1
@@ -10,4 +10,5 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (20-707): Function state mutability can be restricted to pure
|
||||
// TypeError: (153-250): Type rational_const 9208...(70 digits omitted)...7637 / 1000...(71 digits omitted)...0000 is not implicitly convertible to expected type ufixed256x77, but it can be explicitly converted.
|
||||
// TypeError: (470-566): Type rational_const -933...(70 digits omitted)...0123 / 1000...(70 digits omitted)...0000 is not implicitly convertible to expected type fixed256x76, but it can be explicitly converted.
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
contract C {
|
||||
function literalToUFixed() public pure {
|
||||
ufixed8x2 a = 0.10;
|
||||
ufixed8x2 b = 0.00;
|
||||
ufixed8x2 c = 2.55;
|
||||
a; b; c;
|
||||
}
|
||||
function literalToFixed() public pure {
|
||||
fixed8x1 a = 0.1;
|
||||
fixed8x1 b = 12.7;
|
||||
fixed8x1 c = -12.8;
|
||||
a; b; c;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
@@ -2,3 +2,4 @@ contract C {
|
||||
fixed8x80 a = -1e-100;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (29-36): Type rational_const -1 / 1000...(93 digits omitted)...0000 is not implicitly convertible to expected type fixed8x80, but it can be explicitly converted.
|
||||
|
||||
Reference in New Issue
Block a user