Try adding a pair of brackets after gas(800)
:
feed.info.value(10).gas(800)
becomes
feed.info.value(10).gas(800)()
What the error message is trying to tell you is that you're telling it to assign a function - one which returns (uint256) to be specific - to a uint called attribut, when what you need to do is call that function, and assign the result of calling it to the uint called attribut.
TL;DR;
Copy the values individually as you cannot copy from one storage type to another and you cannot cast a fixed length array to a dynamic length array.
Casting arrays from different storage mechanisms
First things first, you cannot directly cast a calldata/memory array to a storage array due to storage being a reference to a storage value and memory is a reference to memory (calldata is copied to memory). What you will have to do is iterate over the array and copy values one at a time as they are two different storage mechanisms and they interact with data in different ways.
/home/codewarrior/solidity/contracts/solution.sol:18:15: TypeError:
Type int256[3] memory[] memory is not implicitly convertible to
expected type uint256[3] storage ref[] storage ref.
arr = board;
^---^
Casting fixed length to dynamic arrays
Secondly, you can't cast a fixed length array to a dynamic array as they are completely different data types. A fixed length array has no length property because it has a deterministic length.
,/home/codewarrior/solidity/contracts/solution.sol:22:26: TypeError:
Invalid type for argument in function call. Invalid implicit
conversion from uint256[3] storage ref to int256[] memory requested.
int h1 = checkH(arr[1]);
This is how the arrays look in memory:
Fixed length array
uint[2] fixedArray;
The memory for a fixed length array is reserved and the length cannot be modified.
-----------------------------------
| Element | Element |
| n1 | n2 |
-----------------------------------
| 32 bytes | 32 bytes |
-----------------------------------
| 0x01 | 0x02 |
-----------------------------------
Just a sequence of elements of their data type length.
Dynamic array in memory/storage
Although they use different storage mechanisms (storage is stored as part of the blockchain data and memory in temporary memory on execution), they have the same structure. As we already know that they are a uint256 we know their data size and only need to store the length and the values.
----------------------------------------------------
| Length of | Element | Element |
| array | n1 | n2 |
----------------------------------------------------
| 32 bytes | 32 bytes | 32 bytes |
----------------------------------------------------
| 0x02 | 0x01 | 0x02 |
----------------------------------------------------
This time we have an extra length value, but again still a sequence of elements. The only key difference is that this sequence is mutable.
It's probably worth also mentioning call data.
Dynamic array in call data
When handling call data it has a prefix of the data type size which is important if you're creating this value from assembly or such.
---------------------------------------------------------------------
| Data Type | Length of | Element | Element |
| Size | array | n1 | n2 |
---------------------------------------------------------------------
| 32 bytes | 32 bytes | 32 bytes | 32 bytes |
---------------------------------------------------------------------
| 0x20 | 0x02 | 0x01 | 0x02 |
---------------------------------------------------------------------
Despite the extra 32 bytes of data for the data type length, it's still the same mutable sequence of data.
Best Answer
You have
uint256 temp
andint256 _temp
.In
_temp = temp
, you are trying to assign the value of auint256
variable to anint256
variable.The compilation error tells you that you cannot use an implicit conversion, so use an explicit conversion instead: