Skip to content

Commit

Permalink
internal/core: re-allow new definitions in closed structs
Browse files Browse the repository at this point in the history
This is a partial revert of CL 8062, specifically the implementation
change that disallowed new definitions in closed structs. The spec part
of CL 8062 remains.

This change is being reverted until fixes for #635 and other issues
discovered as part of the beta.1 release are resolved. #635 is a fairly
major problem - it's not unlikely people will run into correctness
issues as a result of it. The change to disallow new definitions in
closed structs will likely require changes from users (changes that
cannot safely be automatically rewritten). At this stage, getting
exposure to the other changes made as part of beta.1 is more important.
Hence the focus is on fixing #635 and friends, providing a more solid
baseline release in the form of beta.2 (which should generally speaking
be a more apples-to-apples comparison with whatever people were using
before beta.1) and _then_ make the breaking change that disallows new
definitions in closed structs.

Change-Id: I7294a2e6156ec4fe1356e489e7937355c11c56f8
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8201
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
myitcv authored and mpvl committed Jan 14, 2021
1 parent 867f71f commit 03aab97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
18 changes: 3 additions & 15 deletions cue/testdata/definitions/visibility.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,15 @@ foo: #foo & {
#name: "baz"
}
-- out/eval --
Errors:
foo: field `#name` not allowed:
./in.cue:4:6
./in.cue:9:5

Result:
(_|_){
// [eval]
(struct){
#foo: (#struct){
name: (string){ string }
}
foo: (_|_){
// [eval]
foo: (#struct){
name: (string){ string }
_name: (string){ "foo" }
_#name: (string){ "bar" }
#name: (_|_){
// [eval] foo: field `#name` not allowed:
// ./in.cue:4:6
// ./in.cue:9:5
}
#name: (string){ "baz" }
}
}
-- out/compile --
Expand Down
3 changes: 2 additions & 1 deletion internal/core/adt/closed2.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ func verifyArc2(ctx *OpContext, f Feature, v *Vertex, isClosed bool) (found bool
return true, nil
}

if f.IsHidden() && f != InvalidLabel {
if !f.IsString() && f != InvalidLabel {
// if f.IsHidden() && f != InvalidLabel {
return false, nil
}

Expand Down

0 comments on commit 03aab97

Please sign in to comment.