Change error message and add tests

This commit is contained in:
Leonardo Alt 2019-01-17 13:54:31 +01:00
parent c96b760c47
commit 83e7233bb8
5 changed files with 35 additions and 1 deletions

View File

@ -1487,7 +1487,7 @@ void TypeChecker::typeCheckABIEncodeFunctions(
{
m_errorReporter.typeError(
arguments[i]->location(),
"Fixed point numbers cannot yet be encoded."
"Fractional numbers cannot yet be encoded."
);
continue;
}

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.