Skip to content

S-Expr: Parameter bindings created multiple times from unknown variable #21

Description

@ashiven

The following term gets translated to slotted-sexpr incorrectly:

fun extern binding(n1 n2: Nat, arg: «%core.nat.mul (n1, n2); Nat»): «%core.nat.mul (n1, n2); Nat» =
    let mapper = %rise.map @(%core.nat.mul (n1, n2)) f;
    return (mapper arg);

The resulting sexpr creates two invalid bindings for n1 and n2 that extract from some variable that was never bound:

(root extern binding
    (fun
        $_41120
        (scope
            (lit ff Bool)
            (let
                $n1_41093
                (scope
                    (extract
                        (var $_41092)          <-------------- never bound
                        (lit 0 (idx (lit 3 Nat))))
            (let
                $n2_41094
                (scope
                    (extract
                        (var $_41092)          <-------------- never bound
                        (lit 1 (idx (lit 3 Nat))))
            (let
                $return_41139
                (scope
                    (extract
                        (var $_41120)
                        (lit tt Bool))
            (let
                $n1_41132
                (scope
                    (extract
                        (extract
                            (var $_41120)
                            (lit ff Bool))
                        (lit 0 (idx (lit 3 Nat))))
            (let
                $n2_41133
                (scope
                    (extract
                        (extract
                            (var $_41120)
                            (lit ff Bool))
                        (lit 1 (idx (lit 3 Nat))))
...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions