cue icon indicating copy to clipboard operation
cue copied to clipboard

internal/core/adt: closedness structure discarded for dynamic fields

Open mpvl opened this issue 3 years ago • 0 comments

What version of CUE are you using (cue version)?

cue version v0.0.0-20220812162136-7ad3777f9942

   -compiler gc
 CGO_ENABLED 1
      GOARCH amd64
        GOOS darwin
     GOAMD64 v1
         vcs git
vcs.revision 7ad3777f9942877b60cd9036c84dc9f6a0c0a951
    vcs.time 2022-08-12T16:21:36Z
vcs.modified true

Does this issue reproduce with the latest release?

yes

What did you do?

#A: a: b: {
	c: string
	d: 2
}
#B: a: b: {
	c: *"d" | string
	"\(c)": 2
}

x: #A & #B

v: x.a & {
	b: c: "e"
}

What did you expect to see?

Failure: set of fields in #B in x is not the same as in #A after mixing in new structure.

What did you see instead?

Success

Analysis

CUE's closedness algorithm assumes that it does not need to check the internal consistency of closedness of fields of conjuncts it refers from a single field, as it assumes that any errors would have already surfaced there. This is not necessarily correct, however, if the list of fields contains dynamic fields. In other words, closedness should always carry over.

This is related to a possible algorithmic performance boost mentioned in #1871.

mpvl avatar Aug 23 '22 09:08 mpvl