Skip to content

Instantly share code, notes, and snippets.

@hrkrshnn
Created February 5, 2021 16:03
Show Gist options
  • Save hrkrshnn/331a7447477238cf6c6375f54ed634ea to your computer and use it in GitHub Desktop.
Save hrkrshnn/331a7447477238cf6c6375f54ed634ea to your computer and use it in GitHub Desktop.

Table of Contents

  1. Switch statement
  2. Argument issue
  3. Argument issue
  4. switch statement

Switch statement

contract A { modifier m1() {_;} }
contract B is A {
	constructor() A() m1(){ }
}

Internal compiler error during compilation:
/solidity/libsolidity/codegen/ir/IRGenerator.cpp(64): Throw in function std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > solidity::frontend::IRGenerator::run(const solidity::frontend::ContractDefinition&, const std::map<const solidity::frontend::ContractDefinition*, const std::basic_string_view<char> >&)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: 
object "B_16" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        constructor_B_16()

        codecopy(0, dataoffset("B_16_deployed"), datasize("B_16_deployed"))

        return(0, datasize("B_16_deployed"))

        function constructor_A_5() {

        }

        function constructor_B_16() {

            constructor_A_5()

            modifier_A_10()
        }

        function fun__15_inner() {

        }

        function modifier_m1_12() {

            fun__15_inner()

        }

    }
    object "B_16_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

        }

    }

}



Invalid IR generated:
Error: Function not found.

Warning: "switch" statement with only a default case.



[solidity::util::tag_comment*] = 
object "B_16" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        constructor_B_16()

        codecopy(0, dataoffset("B_16_deployed"), datasize("B_16_deployed"))

        return(0, datasize("B_16_deployed"))

        function constructor_A_5() {

        }

        function constructor_B_16() {

            constructor_A_5()

            modifier_A_10()
        }

        function fun__15_inner() {

        }

        function modifier_m1_12() {

            fun__15_inner()

        }

    }
    object "B_16_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

        }

    }

}



Invalid IR generated:
Error: Function not found.

Warning: "switch" statement with only a default case.

Argument issue

contract C {
	function() external  x;
	function f() public {delete x; }
}

Internal compiler error during compilation:
/solidity/libsolidity/codegen/ir/IRGenerator.cpp(64): Throw in function std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > solidity::frontend::IRGenerator::run(const solidity::frontend::ContractDefinition&, const std::map<const solidity::frontend::ContractDefinition*, const std::basic_string_view<char> >&)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: 
object "C_12" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        constructor_C_12()

        codecopy(0, dataoffset("C_12_deployed"), datasize("C_12_deployed"))

        return(0, datasize("C_12_deployed"))

        function constructor_C_12() {

        }

    }
    object "C_12_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                case 0x26121ff0
                {
                    // f()
                    if callvalue() { revert(0, 0) }
                    abi_decode_tuple_(4, calldatasize())
                    fun_f_11()
                    let memPos := allocateMemory(0)
                    let memEnd := abi_encode_tuple__to__fromStack(memPos  )
                    return(memPos, sub(memEnd, memPos))
                }

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function abi_decode_tuple_(headStart, dataEnd)   {
                if slt(sub(dataEnd, headStart), 0) { revert(0, 0) }

            }

            function abi_encode_tuple__to__fromStack(headStart ) -> tail {
                tail := add(headStart, 0)

            }

            function allocateMemory(size) -> memPtr {
                memPtr := mload(64)
                let newFreePtr := add(memPtr, size)
                // protect against overflow
                if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
                mstore(64, newFreePtr)
            }

            function combine_external_function_id(addr, selector) -> combined {
                combined := shift_left_64(or(shift_left_32(addr), and(selector, 0xffffffff)))
            }

            function convert_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(addr, functionId) -> outAddr, outFunctionId {
                outAddr := addr
                outFunctionId := functionId
            }

            function fun_f_11() {

                storage_set_to_zero_t_function_external_nonpayable$__$returns$__$(0x00, 0)

            }

            function panic_error_0x41() {
                mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
                mstore(4, 0x41)
                revert(0, 0x24)
            }

            function prepare_store_t_bytes24(value) -> ret {
                ret := shift_right_64_unsigned(value)
            }

            function prepare_store_t_function_external_nonpayable$__$returns$__$(addr, selector) -> ret {
                ret := prepare_store_t_bytes24(combine_external_function_id(addr, selector))
            }

            function shift_left_32(value) -> newValue {
                newValue :=

                shl(32, value)

            }

            function shift_left_64(value) -> newValue {
                newValue :=

                shl(64, value)

            }

            function shift_left_dynamic(bits, value) -> newValue {
                newValue :=

                shl(bits, value)

            }

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

            function shift_right_64_unsigned(value) -> newValue {
                newValue :=

                shr(64, value)

            }

            function storage_set_to_zero_t_function_external_nonpayable$__$returns$__$(slot, offset) {
                update_storage_value_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(slot, offset, zero_value_for_split_t_function_external_nonpayable$__$returns$__$())
            }

            function update_byte_slice_dynamic24(value, shiftBytes, toInsert) -> result {
                let shiftBits := mul(shiftBytes, 8)
                let mask := shift_left_dynamic(shiftBits, 0xffffffffffffffffffffffffffffffffffffffffffffffff)
                toInsert := shift_left_dynamic(shiftBits, toInsert)
                value := and(value, not(mask))
                result := or(value, and(toInsert, mask))
            }

            function update_storage_value_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(slot, offset, value_0, value_1) {
                let convertedValue_0, convertedValue_1 := convert_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(value_0, value_1)
                sstore(slot, update_byte_slice_dynamic24(sload(slot), offset, prepare_store_t_function_external_nonpayable$__$returns$__$(convertedValue_0, convertedValue_1)))
            }

            function zero_value_for_split_t_function_external_nonpayable$__$returns$__$() -> retAddress, retFunction {
                retAddress := 0
                retFunction := 0
            }

        }

    }

}



Invalid IR generated:
Error: Function expects 4 arguments but got 3.

Error: Expected expression to evaluate to one value, but got 2 values instead.



[solidity::util::tag_comment*] = 
object "C_12" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        constructor_C_12()

        codecopy(0, dataoffset("C_12_deployed"), datasize("C_12_deployed"))

        return(0, datasize("C_12_deployed"))

        function constructor_C_12() {

        }

    }
    object "C_12_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                case 0x26121ff0
                {
                    // f()
                    if callvalue() { revert(0, 0) }
                    abi_decode_tuple_(4, calldatasize())
                    fun_f_11()
                    let memPos := allocateMemory(0)
                    let memEnd := abi_encode_tuple__to__fromStack(memPos  )
                    return(memPos, sub(memEnd, memPos))
                }

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function abi_decode_tuple_(headStart, dataEnd)   {
                if slt(sub(dataEnd, headStart), 0) { revert(0, 0) }

            }

            function abi_encode_tuple__to__fromStack(headStart ) -> tail {
                tail := add(headStart, 0)

            }

            function allocateMemory(size) -> memPtr {
                memPtr := mload(64)
                let newFreePtr := add(memPtr, size)
                // protect against overflow
                if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
                mstore(64, newFreePtr)
            }

            function combine_external_function_id(addr, selector) -> combined {
                combined := shift_left_64(or(shift_left_32(addr), and(selector, 0xffffffff)))
            }

            function convert_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(addr, functionId) -> outAddr, outFunctionId {
                outAddr := addr
                outFunctionId := functionId
            }

            function fun_f_11() {

                storage_set_to_zero_t_function_external_nonpayable$__$returns$__$(0x00, 0)

            }

            function panic_error_0x41() {
                mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
                mstore(4, 0x41)
                revert(0, 0x24)
            }

            function prepare_store_t_bytes24(value) -> ret {
                ret := shift_right_64_unsigned(value)
            }

            function prepare_store_t_function_external_nonpayable$__$returns$__$(addr, selector) -> ret {
                ret := prepare_store_t_bytes24(combine_external_function_id(addr, selector))
            }

            function shift_left_32(value) -> newValue {
                newValue :=

                shl(32, value)

            }

            function shift_left_64(value) -> newValue {
                newValue :=

                shl(64, value)

            }

            function shift_left_dynamic(bits, value) -> newValue {
                newValue :=

                shl(bits, value)

            }

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

            function shift_right_64_unsigned(value) -> newValue {
                newValue :=

                shr(64, value)

            }

            function storage_set_to_zero_t_function_external_nonpayable$__$returns$__$(slot, offset) {
                update_storage_value_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(slot, offset, zero_value_for_split_t_function_external_nonpayable$__$returns$__$())
            }

            function update_byte_slice_dynamic24(value, shiftBytes, toInsert) -> result {
                let shiftBits := mul(shiftBytes, 8)
                let mask := shift_left_dynamic(shiftBits, 0xffffffffffffffffffffffffffffffffffffffffffffffff)
                toInsert := shift_left_dynamic(shiftBits, toInsert)
                value := and(value, not(mask))
                result := or(value, and(toInsert, mask))
            }

            function update_storage_value_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(slot, offset, value_0, value_1) {
                let convertedValue_0, convertedValue_1 := convert_t_function_external_nonpayable$__$returns$__$_to_t_function_external_nonpayable$__$returns$__$(value_0, value_1)
                sstore(slot, update_byte_slice_dynamic24(sload(slot), offset, prepare_store_t_function_external_nonpayable$__$returns$__$(convertedValue_0, convertedValue_1)))
            }

            function zero_value_for_split_t_function_external_nonpayable$__$returns$__$() -> retAddress, retFunction {
                retAddress := 0
                retFunction := 0
            }

        }

    }

}



Invalid IR generated:
Error: Function expects 4 arguments but got 3.

Error: Expected expression to evaluate to one value, but got 2 values instead.

Argument issue

contract C {
  function() external returns (int) x;
  function f() public { delete x; }
}

Internal compiler error during compilation:
/solidity/libsolidity/codegen/ir/IRGenerator.cpp(64): Throw in function std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > solidity::frontend::IRGenerator::run(const solidity::frontend::ContractDefinition&, const std::map<const solidity::frontend::ContractDefinition*, const std::basic_string_view<char> >&)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: 
object "C_14" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        constructor_C_14()

        codecopy(0, dataoffset("C_14_deployed"), datasize("C_14_deployed"))

        return(0, datasize("C_14_deployed"))

        function constructor_C_14() {

        }

    }
    object "C_14_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                case 0x26121ff0
                {
                    // f()
                    if callvalue() { revert(0, 0) }
                    abi_decode_tuple_(4, calldatasize())
                    fun_f_13()
                    let memPos := allocateMemory(0)
                    let memEnd := abi_encode_tuple__to__fromStack(memPos  )
                    return(memPos, sub(memEnd, memPos))
                }

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function abi_decode_tuple_(headStart, dataEnd)   {
                if slt(sub(dataEnd, headStart), 0) { revert(0, 0) }

            }

            function abi_encode_tuple__to__fromStack(headStart ) -> tail {
                tail := add(headStart, 0)

            }

            function allocateMemory(size) -> memPtr {
                memPtr := mload(64)
                let newFreePtr := add(memPtr, size)
                // protect against overflow
                if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
                mstore(64, newFreePtr)
            }

            function combine_external_function_id(addr, selector) -> combined {
                combined := shift_left_64(or(shift_left_32(addr), and(selector, 0xffffffff)))
            }

            function convert_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(addr, functionId) -> outAddr, outFunctionId {
                outAddr := addr
                outFunctionId := functionId
            }

            function fun_f_13() {

                storage_set_to_zero_t_function_external_nonpayable$__$returns$_t_int256_$(0x00, 0)

            }

            function panic_error_0x41() {
                mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
                mstore(4, 0x41)
                revert(0, 0x24)
            }

            function prepare_store_t_bytes24(value) -> ret {
                ret := shift_right_64_unsigned(value)
            }

            function prepare_store_t_function_external_nonpayable$__$returns$_t_int256_$(addr, selector) -> ret {
                ret := prepare_store_t_bytes24(combine_external_function_id(addr, selector))
            }

            function shift_left_32(value) -> newValue {
                newValue :=

                shl(32, value)

            }

            function shift_left_64(value) -> newValue {
                newValue :=

                shl(64, value)

            }

            function shift_left_dynamic(bits, value) -> newValue {
                newValue :=

                shl(bits, value)

            }

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

            function shift_right_64_unsigned(value) -> newValue {
                newValue :=

                shr(64, value)

            }

            function storage_set_to_zero_t_function_external_nonpayable$__$returns$_t_int256_$(slot, offset) {
                update_storage_value_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(slot, offset, zero_value_for_split_t_function_external_nonpayable$__$returns$_t_int256_$())
            }

            function update_byte_slice_dynamic24(value, shiftBytes, toInsert) -> result {
                let shiftBits := mul(shiftBytes, 8)
                let mask := shift_left_dynamic(shiftBits, 0xffffffffffffffffffffffffffffffffffffffffffffffff)
                toInsert := shift_left_dynamic(shiftBits, toInsert)
                value := and(value, not(mask))
                result := or(value, and(toInsert, mask))
            }

            function update_storage_value_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(slot, offset, value_0, value_1) {
                let convertedValue_0, convertedValue_1 := convert_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(value_0, value_1)
                sstore(slot, update_byte_slice_dynamic24(sload(slot), offset, prepare_store_t_function_external_nonpayable$__$returns$_t_int256_$(convertedValue_0, convertedValue_1)))
            }

            function zero_value_for_split_t_function_external_nonpayable$__$returns$_t_int256_$() -> retAddress, retFunction {
                retAddress := 0
                retFunction := 0
            }

        }

    }

}



Invalid IR generated:
Error: Function expects 4 arguments but got 3.

Error: Expected expression to evaluate to one value, but got 2 values instead.



[solidity::util::tag_comment*] = 
object "C_14" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        constructor_C_14()

        codecopy(0, dataoffset("C_14_deployed"), datasize("C_14_deployed"))

        return(0, datasize("C_14_deployed"))

        function constructor_C_14() {

        }

    }
    object "C_14_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                case 0x26121ff0
                {
                    // f()
                    if callvalue() { revert(0, 0) }
                    abi_decode_tuple_(4, calldatasize())
                    fun_f_13()
                    let memPos := allocateMemory(0)
                    let memEnd := abi_encode_tuple__to__fromStack(memPos  )
                    return(memPos, sub(memEnd, memPos))
                }

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function abi_decode_tuple_(headStart, dataEnd)   {
                if slt(sub(dataEnd, headStart), 0) { revert(0, 0) }

            }

            function abi_encode_tuple__to__fromStack(headStart ) -> tail {
                tail := add(headStart, 0)

            }

            function allocateMemory(size) -> memPtr {
                memPtr := mload(64)
                let newFreePtr := add(memPtr, size)
                // protect against overflow
                if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
                mstore(64, newFreePtr)
            }

            function combine_external_function_id(addr, selector) -> combined {
                combined := shift_left_64(or(shift_left_32(addr), and(selector, 0xffffffff)))
            }

            function convert_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(addr, functionId) -> outAddr, outFunctionId {
                outAddr := addr
                outFunctionId := functionId
            }

            function fun_f_13() {

                storage_set_to_zero_t_function_external_nonpayable$__$returns$_t_int256_$(0x00, 0)

            }

            function panic_error_0x41() {
                mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
                mstore(4, 0x41)
                revert(0, 0x24)
            }

            function prepare_store_t_bytes24(value) -> ret {
                ret := shift_right_64_unsigned(value)
            }

            function prepare_store_t_function_external_nonpayable$__$returns$_t_int256_$(addr, selector) -> ret {
                ret := prepare_store_t_bytes24(combine_external_function_id(addr, selector))
            }

            function shift_left_32(value) -> newValue {
                newValue :=

                shl(32, value)

            }

            function shift_left_64(value) -> newValue {
                newValue :=

                shl(64, value)

            }

            function shift_left_dynamic(bits, value) -> newValue {
                newValue :=

                shl(bits, value)

            }

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

            function shift_right_64_unsigned(value) -> newValue {
                newValue :=

                shr(64, value)

            }

            function storage_set_to_zero_t_function_external_nonpayable$__$returns$_t_int256_$(slot, offset) {
                update_storage_value_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(slot, offset, zero_value_for_split_t_function_external_nonpayable$__$returns$_t_int256_$())
            }

            function update_byte_slice_dynamic24(value, shiftBytes, toInsert) -> result {
                let shiftBits := mul(shiftBytes, 8)
                let mask := shift_left_dynamic(shiftBits, 0xffffffffffffffffffffffffffffffffffffffffffffffff)
                toInsert := shift_left_dynamic(shiftBits, toInsert)
                value := and(value, not(mask))
                result := or(value, and(toInsert, mask))
            }

            function update_storage_value_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(slot, offset, value_0, value_1) {
                let convertedValue_0, convertedValue_1 := convert_t_function_external_nonpayable$__$returns$_t_int256_$_to_t_function_external_nonpayable$__$returns$_t_int256_$(value_0, value_1)
                sstore(slot, update_byte_slice_dynamic24(sload(slot), offset, prepare_store_t_function_external_nonpayable$__$returns$_t_int256_$(convertedValue_0, convertedValue_1)))
            }

            function zero_value_for_split_t_function_external_nonpayable$__$returns$_t_int256_$() -> retAddress, retFunction {
                retAddress := 0
                retFunction := 0
            }

        }

    }

}



Invalid IR generated:
Error: Function expects 4 arguments but got 3.

Error: Expected expression to evaluate to one value, but got 2 values instead.

switch statement

contract D {
  constructor(function() external returns (uint)) {}
}

Internal compiler error during compilation:
/solidity/libsolidity/codegen/ir/IRGenerator.cpp(64): Throw in function std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > solidity::frontend::IRGenerator::run(const solidity::frontend::ContractDefinition&, const std::map<const solidity::frontend::ContractDefinition*, const std::basic_string_view<char> >&)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: 
object "D_11" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        let _1 := copy_arguments_for_constructor_10_object_D_11()
        constructor_D_11(_1)

        codecopy(0, dataoffset("D_11_deployed"), datasize("D_11_deployed"))

        return(0, datasize("D_11_deployed"))

        function abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(offset, end) -> fun {
            fun := mload(offset)
            validator_revert_t_function_external_nonpayable$__$returns$_t_uint256_$(fun)
        }

        function abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory_onStack(offset, end) -> addr, function_selector {
            addr, function_selector := split_external_function_id(abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(offset, end))
        }

        function abi_decode_tuple_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(headStart, dataEnd) -> value0, value1 {
            if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }

            {

                let offset := 0

                value0, value1 := abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory_onStack(add(headStart, offset), dataEnd)
            }

        }

        function allocateMemory(size) -> memPtr {
            memPtr := mload(64)
            let newFreePtr := add(memPtr, size)
            // protect against overflow
            if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
            mstore(64, newFreePtr)
        }

        function cleanup_t_bytes24(value) -> cleaned {
            cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000)
        }

        function cleanup_t_function_external_nonpayable$__$returns$_t_uint256_$(value) -> cleaned {
            cleaned := cleanup_t_bytes24(value)
        }

        function constructor_D_11(vloc__6_address, vloc__6_functionSelector) {

        }

        function copy_arguments_for_constructor_10_object_D_11() -> ret_param_0 {
            let programSize := datasize("D_11")
            let argSize := sub(codesize(), programSize)

            let memoryDataOffset := allocateMemory(argSize)
            codecopy(memoryDataOffset, programSize, argSize)

            ret_param_0 := abi_decode_tuple_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(memoryDataOffset, add(memoryDataOffset, argSize))
        }

        function panic_error_0x41() {
            mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
            mstore(4, 0x41)
            revert(0, 0x24)
        }

        function shift_right_32_unsigned(value) -> newValue {
            newValue :=

            shr(32, value)

        }

        function shift_right_64_unsigned(value) -> newValue {
            newValue :=

            shr(64, value)

        }

        function split_external_function_id(combined) -> addr, selector {
            combined := shift_right_64_unsigned(combined)
            selector := and(combined, 0xffffffff)
            addr := shift_right_32_unsigned(combined)
        }

        function validator_revert_t_function_external_nonpayable$__$returns$_t_uint256_$(value) {
            if iszero(eq(value, cleanup_t_function_external_nonpayable$__$returns$_t_uint256_$(value))) { revert(0, 0) }
        }

    }
    object "D_11_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

        }

    }

}



Invalid IR generated:
Error: Function expects 2 arguments but got 1.

Error: Variable count does not match number of values (1 vs. 2)

Warning: "switch" statement with only a default case.



[solidity::util::tag_comment*] = 
object "D_11" {
    code {
        mstore(64, 128)
        if callvalue() { revert(0, 0) }

        let _1 := copy_arguments_for_constructor_10_object_D_11()
        constructor_D_11(_1)

        codecopy(0, dataoffset("D_11_deployed"), datasize("D_11_deployed"))

        return(0, datasize("D_11_deployed"))

        function abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(offset, end) -> fun {
            fun := mload(offset)
            validator_revert_t_function_external_nonpayable$__$returns$_t_uint256_$(fun)
        }

        function abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory_onStack(offset, end) -> addr, function_selector {
            addr, function_selector := split_external_function_id(abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(offset, end))
        }

        function abi_decode_tuple_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(headStart, dataEnd) -> value0, value1 {
            if slt(sub(dataEnd, headStart), 32) { revert(0, 0) }

            {

                let offset := 0

                value0, value1 := abi_decode_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory_onStack(add(headStart, offset), dataEnd)
            }

        }

        function allocateMemory(size) -> memPtr {
            memPtr := mload(64)
            let newFreePtr := add(memPtr, size)
            // protect against overflow
            if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
            mstore(64, newFreePtr)
        }

        function cleanup_t_bytes24(value) -> cleaned {
            cleaned := and(value, 0xffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000)
        }

        function cleanup_t_function_external_nonpayable$__$returns$_t_uint256_$(value) -> cleaned {
            cleaned := cleanup_t_bytes24(value)
        }

        function constructor_D_11(vloc__6_address, vloc__6_functionSelector) {

        }

        function copy_arguments_for_constructor_10_object_D_11() -> ret_param_0 {
            let programSize := datasize("D_11")
            let argSize := sub(codesize(), programSize)

            let memoryDataOffset := allocateMemory(argSize)
            codecopy(memoryDataOffset, programSize, argSize)

            ret_param_0 := abi_decode_tuple_t_function_external_nonpayable$__$returns$_t_uint256_$_fromMemory(memoryDataOffset, add(memoryDataOffset, argSize))
        }

        function panic_error_0x41() {
            mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
            mstore(4, 0x41)
            revert(0, 0x24)
        }

        function shift_right_32_unsigned(value) -> newValue {
            newValue :=

            shr(32, value)

        }

        function shift_right_64_unsigned(value) -> newValue {
            newValue :=

            shr(64, value)

        }

        function split_external_function_id(combined) -> addr, selector {
            combined := shift_right_64_unsigned(combined)
            selector := and(combined, 0xffffffff)
            addr := shift_right_32_unsigned(combined)
        }

        function validator_revert_t_function_external_nonpayable$__$returns$_t_uint256_$(value) {
            if iszero(eq(value, cleanup_t_function_external_nonpayable$__$returns$_t_uint256_$(value))) { revert(0, 0) }
        }

    }
    object "D_11_deployed" {
        code {
            mstore(64, 128)

            if iszero(lt(calldatasize(), 4))
            {
                let selector := shift_right_224_unsigned(calldataload(0))
                switch selector

                default {}
            }
            if iszero(calldatasize()) {  }
            revert(0, 0)

            function shift_right_224_unsigned(value) -> newValue {
                newValue :=

                shr(224, value)

            }

        }

    }

}



Invalid IR generated:
Error: Function expects 2 arguments but got 1.

Error: Variable count does not match number of values (1 vs. 2)

Warning: "switch" statement with only a default case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment