@@ -105,29 +105,28 @@ func TestStdlibUUID(t *testing.T) {
105105 assertUUID (t , tagged .Properties ["alias" ])
106106 })
107107
108- t .Run ("an EMBEDDED uuid.UUID is dropped, with a warning — quirks-open.md Q33" , func (t * testing.T ) {
109- // Current behaviour, not desired behaviour. uuid.UUID has an array underlying type, so
110- // buildNamedEmbedded's switch falls to its default arm (only the *interface* arm consults
111- // applyStdlibSpecials) and skips the embed. Go itself renders the whole struct as a bare
112- // string via the promoted MarshalText, so "name" is not on the wire either.
108+ t .Run ("an EMBEDDED uuid.UUID becomes a property named after the type" , func (t * testing.T ) {
109+ // uuid.UUID is an array underneath, so embedding it promotes no member and Go keeps the value
110+ // as an ordinary key named UUID — which is what the schema says, built through the identity
111+ // recognizer like any other member. See embed-basic-underlying for the general rule.
113112 //
114- // This is a pre-existing, uuid-agnostic quirk shared with every strfmt.UUID / time.Time
115- // embed; the identity recognizer deliberately does not change it. When Q33 is decided, this
116- // sub-test and the golden move together.
113+ // The promoted MarshalText makes the DEFAULT marshaller render the whole struct as a bare
114+ // string, dropping "name" from the wire. codescan does not model that, by decision: an embed
115+ // means composition, and a composed model round-trips through a hand-written marshaller. See
116+ // schema/README.md#embed-marshaller.
117117 embedder , ok := sp .Definitions ["Embedder" ]
118118 require .TrueT (t , ok )
119119 assert .TrueT (t , embedder .Type .Contains ("object" ))
120- assert .Len (t , embedder .Properties , 1 )
120+ assert .Len (t , embedder .Properties , 2 )
121121 assert .Contains (t , embedder .Properties , "name" )
122+ require .Contains (t , embedder .Properties , "UUID" )
123+ assertUUID (t , embedder .Properties ["UUID" ])
122124
123- var warned bool
125+ // The embed is emitted, so nothing about it is skipped or reported.
124126 for _ , d := range diagnostics {
125- if d .Severity == codescan .SeverityWarning && strings .Contains (d .Message , "buildNamedEmbedded" ) {
126- warned = true
127- break
128- }
127+ assert .FalseT (t , d .Severity == codescan .SeverityWarning && strings .Contains (d .Message , "buildNamedEmbedded" ),
128+ "an embed that is emitted must raise no unsupported-type warning: %s" , d .Message )
129129 }
130- assert .TrueT (t , warned , "the dropped embed must not be silent" )
131130 })
132131
133132 scantest .CompareOrDumpJSON (t , sp , "go127_uuid_spec.json" )
0 commit comments