ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.04k stars 5.7k forks source link

ParserError for JUMP opcode #15361

Closed amit-supraoracles closed 2 weeks ago

amit-supraoracles commented 2 weeks ago

Description

I just want to see how JUMP opcode works but facing ParserError on line 14

Environment

Steps to Reproduce

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract MinimalJumpExample {
    uint256 public result;

    function jumpTest() public {
        assembly {
            let destination := jumpDest  // Label for jump destination
            jump(destination)            // Perform the jump

            result := 1                  // This will be skipped

            jumpDest:
            result := 2                  // Execution continues here
        }
    }
}
clonker commented 2 weeks ago

There is no Yul builtin for the JUMP opcode (or JUMPI / JUMPDEST for that mattter), see here: https://docs.soliditylang.org/en/v0.8.26/yul.html#evm-dialect You can check out https://www.evm.codes/ if you want to play around with it regardless.

amit-supraoracles commented 2 weeks ago

There is no Yul builtin for the JUMP opcode (or JUMPI / JUMPDEST for that mattter), see here: https://docs.soliditylang.org/en/v0.8.26/yul.html#evm-dialect You can check out https://www.evm.codes/ if you want to play around with it regardless.

Thanks @clonker !! image