-- in.cue --
_schema // embed schema through indirections
_schema: #Schema @test(shareID=topSchema)
#Schema: {
	@test(shareID=topSchema)
	a?: b?: string
}
a: b: "foo"
c: "foo"


x: {
	_schema // embed schema through indirections
	_schema: #Schema @test(shareID=xSchema)
	#Schema: {
		@test(shareID=xSchema)
		a?: b?: string
	}
	a: b: "foo"
	c: "foo"
}

@test(eq, {
	a: b: "foo"
	_schema: a?: b?: string
	#Schema: a?: b?: string
	c: "foo"
	x: {
		a: b: "foo"
		_schema: a?: b?: string
		#Schema: a?: b?: string
		c: "foo"
	}
})
// TODO(inline): fix sharing detection across hidden fields.
@test(debug, """
	(#struct){
	  _schema: ~(#Schema)
	  #Schema: (#struct){
	    a?: (#struct){
	      b?: (string){ string }
	    }
	  }
	  a: (#struct){
	    b: (string){ "foo" }
	  }
	  c: (string){ "foo" }
	  x: (#struct){
	    _schema: ~(x.#Schema)
	    #Schema: (#struct){
	      a?: (#struct){
	        b?: (string){ string }
	      }
	    }
	    a: (#struct){
	      b: (string){ "foo" }
	    }
	    c: (string){ "foo" }
	  }
	}
	""")
-- out/eval/stats --
Leaks:  0
Freed:  16
Reused: 4
Allocs: 12
Retain: 0

Unifications: 16
Conjuncts:    26
Disjuncts:    0
Notifications: 4

NumCloseIDs: 7
-- out/diff-v2-v3.txt --
Reordering
Verdict: cosmetic -- Field reordering only. No semantic change.
