mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5807 from ethereum/fixed_point_encoding
Return TypeError is fixed point encoding is attempted.
This commit is contained in:
commit
0b14d7a2d6
@ -8,6 +8,7 @@ Compiler Features:
|
|||||||
|
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
* TypeChecker: Return type error if fixed point encoding is attempted instead of throwing ``UnimplementedFeatureError``.
|
||||||
* Yul: Check that arguments to ``dataoffset`` and ``datasize`` are literals at parse time and properly take this into account in the optimizer.
|
* Yul: Check that arguments to ``dataoffset`` and ``datasize`` are literals at parse time and properly take this into account in the optimizer.
|
||||||
* Yul: Parse number literals for detecting duplicate switch cases.
|
* Yul: Parse number literals for detecting duplicate switch cases.
|
||||||
* Yul: Require switch cases to have the same type.
|
* Yul: Require switch cases to have the same type.
|
||||||
|
@ -1482,7 +1482,16 @@ void TypeChecker::typeCheckABIEncodeFunctions(
|
|||||||
|
|
||||||
if (argType->category() == Type::Category::RationalNumber)
|
if (argType->category() == Type::Category::RationalNumber)
|
||||||
{
|
{
|
||||||
if (!argType->mobileType())
|
auto const& rationalType = dynamic_cast<RationalNumberType const&>(*argType);
|
||||||
|
if (rationalType.isFractional())
|
||||||
|
{
|
||||||
|
m_errorReporter.typeError(
|
||||||
|
arguments[i]->location(),
|
||||||
|
"Fractional numbers cannot yet be encoded."
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (!argType->mobileType())
|
||||||
{
|
{
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
arguments[i]->location(),
|
arguments[i]->location(),
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
contract C {
|
||||||
|
function f1() public pure returns (bytes memory) {
|
||||||
|
return abi.encode(0.1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError: (92-95): Fractional numbers cannot yet be encoded.
|
@ -0,0 +1,9 @@
|
|||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
contract C {
|
||||||
|
function f1() public pure returns (bytes memory) {
|
||||||
|
return abi.encode(0.1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||||
|
// TypeError: (126-129): Fractional numbers cannot yet be encoded.
|
@ -0,0 +1,8 @@
|
|||||||
|
contract C {
|
||||||
|
function f1() public pure returns (bytes memory) {
|
||||||
|
return abi.encodePacked(0.1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError: (98-101): Fractional numbers cannot yet be encoded.
|
||||||
|
// TypeError: (103-104): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
|
@ -0,0 +1,10 @@
|
|||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
contract C {
|
||||||
|
function f1() public pure returns (bytes memory) {
|
||||||
|
return abi.encodePacked(0.1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
|
||||||
|
// TypeError: (132-135): Fractional numbers cannot yet be encoded.
|
||||||
|
// TypeError: (137-138): Cannot perform packed encoding for a literal. Please convert it to an explicit type first.
|
Loading…
Reference in New Issue
Block a user