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:
|
||||
* 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.
|
||||
* 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.
|
||||
* 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.
|
||||
* Code Generator: Fix ICE when accessing the members of external functions occupying more than two stack slots.
|
||||
|
||||
|
||||
Solc-Js:
|
||||
|
@ -1140,7 +1140,10 @@ void CompilerUtils::convertType(
|
||||
|
||||
solAssert(_targetType.category() == Type::Category::Array, "");
|
||||
auto const& targetArrayType = dynamic_cast<ArrayType const&>(_targetType);
|
||||
solAssert(typeOnStack.arrayType().isImplicitlyConvertibleTo(targetArrayType), "");
|
||||
solAssert(
|
||||
typeOnStack.arrayType().isImplicitlyConvertibleTo(targetArrayType) ||
|
||||
(typeOnStack.arrayType().isByteArray() && targetArrayType.isByteArray())
|
||||
);
|
||||
solAssert(
|
||||
typeOnStack.arrayType().dataStoredIn(DataLocation::CallData) &&
|
||||
typeOnStack.arrayType().isDynamicallySized() &&
|
||||
|
@ -3222,7 +3222,10 @@ string YulUtilFunctions::conversionFunction(Type const& _from, Type const& _to)
|
||||
solAssert(_to.category() == Type::Category::Array, "");
|
||||
auto const& targetType = dynamic_cast<ArrayType const&>(_to);
|
||||
|
||||
solAssert(fromType.arrayType().isImplicitlyConvertibleTo(targetType), "");
|
||||
solAssert(
|
||||
fromType.arrayType().isImplicitlyConvertibleTo(targetType) ||
|
||||
(fromType.arrayType().isByteArray() && targetType.isByteArray())
|
||||
);
|
||||
solAssert(
|
||||
fromType.arrayType().dataStoredIn(DataLocation::CallData) &&
|
||||
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