Skip to content

Evaluator.visitObjComp doesn't propagate context correctly #357

@Danstahr

Description

@Danstahr

I wasn't yet able to fully root cause the issue but I derived a minimal example

main.jsonnet

local lib = import "libbroken.libsonnet";

{
  base:: {}
}
+ lib.foo()

libbroken.libsonnet

{
  foo()::
    {
      local global = self,

      [iterParam]: global.base {
        foo: iterParam
      }
      for iterParam in ["foo"]
    },
}

The issue seems to be specific to how the for loop (triggering visitObjComp) is handled. The output is generated properly when the lib code is replaced by

libworking.libsonnet

{
  foo()::
    {
      local global = self,

      foo: global.base {
        foo: "bar"
      }
    },
}

It also generates properly if the global variable is omitted and self is used directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions