Skip to content

Order of reference to const triggers failure of function call #7261

Description

@philrz

This fails:

$ echo '{item:1,next:"b.sup"}' > a.sup &&
  super -version &&
  super -c '
const C = {a:1}
fn myfunc(u): ( [from f"{u}"][0] )
values {...myfunc("a.sup"), z:C}'

Version: v0.3.0-357-g0c71fac6a

cannot read data in constant expression at line 3, column 23:
fn myfunc(u): ( [from f"{u}"][0] )
                      ~~~~~~

However if I swap the order of where the reference to the constant C appears in the call to values, it works.

$ super -c '
const C = {a:1}
fn myfunc(u): ( [from f"{u}"][0] )
values {z:C, ...myfunc("a.sup")}'

{z:{a:1},item:1,next:"b.sup"}

Details

Repro is with super commit 0c71fac.

The repro query above is a simplification of a query one of our advisors has been crafting. His query contained references to defined const values that were similarly referenced in calls to user-defined functions, and he was confused because it seemed like he could make the query fail/work by adding seemingly unrelated pipeline elements that happened to have the side effect of changing when the const resolution happens.

While getting Claude's help simplifying the repro query, it also offered its insight into the root cause and a possible approach for a fix, so this is available in a Gist.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions