#inlineImports: true

# TODO: slightly more correct is for _hidden_567475F3.a to be `b` and not resolve.

-- cue.mod/module.cue --
module: "mod.test/a"
language: version: "v0.9.0"

-- in.cue --
import "mod.test/a/pkg"
import "tool/exec"

// Can be inlined.
v: pkg.v.v

// Do not simplify because of multiple usages of enclosing struct.
x: pkg.a.b.c
y: pkg.a.b

// Cannot simplify because of definition.
z: pkg.#Def.f

// Two references to package, but since the second is a scalar, it can be
// hoisted and only one reference remains. So there is still no need for
// a helper.
// TODO: fix this to eliminate the helper.
w: pkg.w
wa: pkg.w.a

// Never expand builtin packages.
run: exec.Run

_hidden: int

-- pkg/pkg.cue --
package pkg

v: v: { x: 3, y: x }

a: b: c: { d: int }

#Def: f: g: int

w: {
	a: _hidden
	_hidden: {a: b} // Mangle this hidden field.
	b: 1
	x: {
		_hidden2: _hidden
		y: _hidden2
	}
}

-- out/self/default --
import (
	"mod.test/a/pkg"
	"tool/exec"
)

// Can be inlined.
v: pkg.v.v

// Do not simplify because of multiple usages of enclosing struct.
x: pkg.a.b.c
y: pkg.a.b

// Cannot simplify because of definition.
z: pkg.#Def.f

// Two references to package, but since the second is a scalar, it can be
// hoisted and only one reference remains. So there is still no need for
// a helper.
// TODO: fix this to eliminate the helper.
w:  pkg.w
wa: pkg.w.a

// Never expand builtin packages.
run:     exec.Run
_hidden: int
-- out/self/expand_imports --
import "tool/exec"

// Can be inlined.
v: {
	x: 3
	y: x
}

// Do not simplify because of multiple usages of enclosing struct.
x: B.c
y: B

// Cannot simplify because of definition.
z: F.#x

// Two references to package, but since the second is a scalar, it can be
// hoisted and only one reference remains. So there is still no need for
// a helper.
// TODO: fix this to eliminate the helper.
w:  W
wa: W.a

// Never expand builtin packages.
run:     exec.Run
_hidden: int

//cue:path: "mod.test/a/pkg".a.b
let B = {
	c: {
		d: int
	}
}

//cue:path: "mod.test/a/pkg".#Def.f
let F = {
	#x: {
		g: int
	}
}

//cue:path: "mod.test/a/pkg".w
let W = {
	a: _hidden_567475F3
	_hidden_567475F3: {
		a: 1
	}
	b: 1
	x: {
		_hidden2_567475F3: _hidden_567475F3
		y:                 _hidden2_567475F3
	}
}
