I am having this error on solc version 0.6.0.

Basically I am returning length of the list and subtract 1 from it, where that value will be assigned to an uint variable.

In general this command used to return the length of the list after the push:

uint length = list.push(Struct({val: value}))

TypeError: Operator - not compatible with types tuple() and int_const 1
uint32 value = uint32(list.push(Interval({endpoint: startTime})) - 1);

I was not getting this error or solc-v0.5.*. I feel like tuples does not return their length any more.

[Q] How could I fix this error?

1 Answer 1


Yes, list.push will not return the length of it anymore.

From https://solidity.readthedocs.io/en/v0.6.0/060-breaking-changes.html#how-to-update-your-code:

Change uint length = array.push(value) to array.push(value);. The new length can be accessed via array.length.

So, now you must do it "manually":

pragma solidity 0.6.0;

contract Test {
    struct Interval {
        uint endpoint;

    Interval[] public list;

    function addItemAndGetLengthMinusOne() public returns(uint) {
        list.push(Interval({endpoint: now}));
        uint value = list.length - 1;

        return value;
  • Ah this is pretty inefficient and will consume additional gas to access list again, I am not sure why they updated like this. So does list.push() return the latest pushed tuple?
    – alper
    Dec 31, 2019 at 14:12
  • I agree. Now, list.push will return the tuple itself, as far as I can gather. Dec 31, 2019 at 14:16
  • Like only list itself?
    – alper
    Dec 31, 2019 at 14:17
  • Not list itself, because that would be the array. I'm not sure at this point, but I think what you get is the encoded tuple. For instance, you cannot do value = list.push(Interval({endpoint: now})).length; That won't work. Dec 31, 2019 at 14:25
  • So I can do as follows: Interval ret = list.push(Interval({endpoint: now})); and than ret.now will return the last push items now variable
    – alper
    Dec 31, 2019 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.