Skip to content

Invalid yul generated for references unwrapped in a match block #188

@d-xo

Description

@d-xo

The following snippet results in yul that is rejected by solc:

data Wrapper = Wrapper(word);
contract C {
    function main() -> word {
        return foo(Wrapper(1));
    }
    function foo(w:Wrapper) -> word {
        let result : word;
        match w {
            | Wrapper(ptr) =>
                //let ptr2 : word = ptr;
                assembly { result := calldataload(ptr) }
        }
        return result;
    }
}
Error: Identifier "ptr" not found.
 --> bug.yul:7:30:
  |
7 |       result := calldataload(ptr)
  |                              ^^^

uncommenting the let ptr2 ... line and using ptr2 as the arg to calldataload fixes the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions