1

I'm writing a proxy contract in Solidity. To forward incoming calls in my fallback function I'm using inline assembly code. I'm a student and the code below is the code my instructor wrote in the tutorial.

I'm receiving the following error with my code though:

Builtin function "gas" must be called.

I'm assuming that Solidity has evolved since the making of the tutorial, but I cannot find anything online (google or the docs).

Here is the code:

assembly {
        let result := delegatecall(gas, implementation, add(data, 0x20), mload(data), 0, 0)
        let size := returndatasize
        let ptr := mload(0x40)
        returndatacopy(ptr, 0, size)
        switch result   
        case 0 {revert(ptr, size)}  
        default{return(ptr, size)}  
}

The error refers to the word "gas" in line 2 which is underlined in red.
Has something changed?

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
EmmerichS
  • 11
  • 2

1 Answers1

5

In older versions of the docs (e.g. v0.4.24) it says that:

For opcodes that do not take arguments, the parentheses can be omitted.

However, newer versions of the docs link to a separate page for the intermediate language, now called Yul. And on that page, the opcodes are now also referred to as "builtin functions", and it appears that omitting the parentheses is no longer allowed.

So you should most likely use gas() instead of gas.

Michael
  • 57,169
  • 9
  • 80
  • 125