exec cue eval ./pkg:foo
-- cue.mod/module.cue --
module: "mod.test"
language: version: "v0.9.0"
-- in.cue --
package foo

import "mod.test/pkg"

#def: {
	_name: d: int
}

d: pkg.#D & {_name: d: int, _val: f: 4}

// TODO: this should fail, as the _name restricting it is in this
// package.
e: pkg.#D & #def & {
	// This should fail as c is disallowed by the _name defined
	// in this package
	_name: c: int

	// This should not fail, as this is a different _val
	_val: g: int
}

f: pkg.#D & {_val: f: 4}

g: f._val
-- pkg/bar.cue --
package pkg

#D: {_val: f: 3}
-- out/compile --
--- in.cue
{
  #def: {
    _name(:foo): {
      d: int
    }
  }
  d: (〈import;"mod.test/pkg"〉.#D & {
    _name(:foo): {
      d: int
    }
    _val(:foo): {
      f: 4
    }
  })
  e: ((〈import;"mod.test/pkg"〉.#D & 〈0;#def〉) & {
    _name(:foo): {
      c: int
    }
    _val(:foo): {
      g: int
    }
  })
  f: (〈import;"mod.test/pkg"〉.#D & {
    _val(:foo): {
      f: 4
    }
  })
  g: 〈0;f〉._val(:foo)
}
