-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/adt: implement required fields.
Introduce the internal and external types to represent required fields. Fixes #2003 Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com> Change-Id: Iff492d01f929cfcc4ef6c36846da5f30d5b70a77 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551206 Reviewed-by: Aram Hăvărneanu <aram@cue.works> Reviewed-by: Roger Peppe <rogpeppe@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
- Loading branch information
Showing
10 changed files
with
232 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
-- in.cue -- | ||
self: t1: { | ||
a?: int | ||
} | ||
|
||
self: t2: { | ||
a!: int | ||
a!: int | ||
} | ||
|
||
unify: t1: p1: { | ||
a!: int | ||
a: int | ||
} | ||
|
||
unify: t1: p2: { | ||
a: int | ||
a!: int | ||
} | ||
|
||
unify: t2: p1: { | ||
a!: int | ||
a?: int | ||
} | ||
|
||
unify: t2: p2: { | ||
a?: int | ||
a!: int | ||
} | ||
#Def: t1: { | ||
a!: int | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
self: { | ||
t1: { | ||
a?: int | ||
} | ||
} | ||
self: { | ||
t2: { | ||
a!: int | ||
a!: int | ||
} | ||
} | ||
unify: { | ||
t1: { | ||
p1: { | ||
a!: int | ||
a: int | ||
} | ||
} | ||
} | ||
unify: { | ||
t1: { | ||
p2: { | ||
a: int | ||
a!: int | ||
} | ||
} | ||
} | ||
unify: { | ||
t2: { | ||
p1: { | ||
a!: int | ||
a?: int | ||
} | ||
} | ||
} | ||
unify: { | ||
t2: { | ||
p2: { | ||
a?: int | ||
a!: int | ||
} | ||
} | ||
} | ||
#Def: { | ||
t1: { | ||
a!: int | ||
} | ||
} | ||
} | ||
-- out/eval/stats -- | ||
Leaks: 0 | ||
Freed: 20 | ||
Reused: 15 | ||
Allocs: 5 | ||
Retain: 0 | ||
|
||
Unifications: 20 | ||
Conjuncts: 31 | ||
Disjuncts: 20 | ||
-- out/eval -- | ||
Errors: | ||
self.t2.a: field is required but not present | ||
unify.t2.p1.a: field is required but not present | ||
unify.t2.p2.a: field is required but not present | ||
|
||
Result: | ||
(struct){ | ||
self: (struct){ | ||
t1: (struct){ | ||
a?: (int){ int } | ||
} | ||
t2: (struct){ | ||
a!: (int){ int } | ||
} | ||
} | ||
unify: (struct){ | ||
t1: (struct){ | ||
p1: (struct){ | ||
a: (int){ int } | ||
} | ||
p2: (struct){ | ||
a: (int){ int } | ||
} | ||
} | ||
t2: (struct){ | ||
p1: (struct){ | ||
a!: (int){ int } | ||
} | ||
p2: (struct){ | ||
a!: (int){ int } | ||
} | ||
} | ||
} | ||
#Def: (#struct){ | ||
t1: (#struct){ | ||
a!: (int){ int } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.