mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix too strict assert for calldata string -> bytes conversions
This commit is contained in:
parent
0b9ab33fce
commit
a550048cf0
@ -12,12 +12,13 @@ Compiler Features:
|
|||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
* Antlr Grammar: Allow builtin names in ``yulPath`` to support ``.address`` in function pointers.
|
* Antlr Grammar: Allow builtin names in ``yulPath`` to support ``.address`` in function pointers.
|
||||||
|
* Code Generator: Fix ICE when accessing the members of external functions occupying more than two stack slots.
|
||||||
|
* Code Generator: Fix ICE when doing an explicit conversion from ``string calldata`` to ``bytes``.
|
||||||
* Control Flow Graph: Perform proper virtual lookup for modifiers for uninitialized variable and unreachable code analysis.
|
* Control Flow Graph: Perform proper virtual lookup for modifiers for uninitialized variable and unreachable code analysis.
|
||||||
* Immutables: Fix wrong error when the constructor of a base contract uses ``return`` and the parent contract contains immutable variables.
|
* Immutables: Fix wrong error when the constructor of a base contract uses ``return`` and the parent contract contains immutable variables.
|
||||||
* IR Generator: Fix IR syntax error when copying storage arrays of structs containing functions.
|
* IR Generator: Fix IR syntax error when copying storage arrays of structs containing functions.
|
||||||
* Natspec: Fix ICE when overriding a struct getter with a Natspec-documented return value and the name in the struct is different.
|
* Natspec: Fix ICE when overriding a struct getter with a Natspec-documented return value and the name in the struct is different.
|
||||||
* TypeChecker: Fix ICE when a constant variable declaration forward references a struct.
|
* TypeChecker: Fix ICE when a constant variable declaration forward references a struct.
|
||||||
* Code Generator: Fix ICE when accessing the members of external functions occupying more than two stack slots.
|
|
||||||
|
|
||||||
|
|
||||||
Solc-Js:
|
Solc-Js:
|
||||||
|
@ -1140,7 +1140,10 @@ void CompilerUtils::convertType(
|
|||||||
|
|
||||||
solAssert(_targetType.category() == Type::Category::Array, "");
|
solAssert(_targetType.category() == Type::Category::Array, "");
|
||||||
auto const& targetArrayType = dynamic_cast<ArrayType const&>(_targetType);
|
auto const& targetArrayType = dynamic_cast<ArrayType const&>(_targetType);
|
||||||
solAssert(typeOnStack.arrayType().isImplicitlyConvertibleTo(targetArrayType), "");
|
solAssert(
|
||||||
|
typeOnStack.arrayType().isImplicitlyConvertibleTo(targetArrayType) ||
|
||||||
|
(typeOnStack.arrayType().isByteArray() && targetArrayType.isByteArray())
|
||||||
|
);
|
||||||
solAssert(
|
solAssert(
|
||||||
typeOnStack.arrayType().dataStoredIn(DataLocation::CallData) &&
|
typeOnStack.arrayType().dataStoredIn(DataLocation::CallData) &&
|
||||||
typeOnStack.arrayType().isDynamicallySized() &&
|
typeOnStack.arrayType().isDynamicallySized() &&
|
||||||
|
@ -3222,7 +3222,10 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
|||||||
solAssert(_to.category() == Type::Category::Array, "");
|
solAssert(_to.category() == Type::Category::Array, "");
|
||||||
auto const& targetType = dynamic_cast<ArrayType const&>(_to);
|
auto const& targetType = dynamic_cast<ArrayType const&>(_to);
|
||||||
|
|
||||||
solAssert(fromType.arrayType().isImplicitlyConvertibleTo(targetType), "");
|
solAssert(
|
||||||
|
fromType.arrayType().isImplicitlyConvertibleTo(targetType) ||
|
||||||
|
(fromType.arrayType().isByteArray() && targetType.isByteArray())
|
||||||
|
);
|
||||||
solAssert(
|
solAssert(
|
||||||
fromType.arrayType().dataStoredIn(DataLocation::CallData) &&
|
fromType.arrayType().dataStoredIn(DataLocation::CallData) &&
|
||||||
fromType.arrayType().isDynamicallySized() &&
|
fromType.arrayType().isDynamicallySized() &&
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
// Triggered ICE before
|
||||||
|
contract C {
|
||||||
|
function f(string calldata data) external pure returns(string memory) {
|
||||||
|
bytes calldata test = bytes(data[:3]);
|
||||||
|
return string(test);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// f(string): 0x20, 3, "123" -> 0x20, 3, "123"
|
Loading…
Reference in New Issue
Block a user