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.