Skip to content

Commit

Permalink
internal/core/adt: patch old status mechanism
Browse files Browse the repository at this point in the history
The new evaluator updates types and values slightly
differently, which could trip assertions that were
designed for the old evaluator.

This fix introduces some workarounds. Once the new
evaluator replaces the old one, this should be
cleaned up.

Issue #2884

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I5291cc59b2808b3841d719287d163d413509c623
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1191583
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
mpvl committed Apr 15, 2024
1 parent 416c163 commit 709cdc5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/core/adt/composite.go
Expand Up @@ -532,7 +532,11 @@ func (v *Vertex) IsUnprocessed() bool {
}

func (v *Vertex) updateStatus(s vertexStatus) {
Assertf(v.status <= s+1, "attempt to regress status from %d to %d", v.Status(), s)
if !isCyclePlaceholder(v.BaseValue) {
if _, ok := v.BaseValue.(*Bottom); !ok {
Assertf(v.status <= s+1, "attempt to regress status from %d to %d", v.Status(), s)
}
}

if s == finalized && v.BaseValue == nil {
// TODO: for debugging.
Expand Down
3 changes: 3 additions & 0 deletions internal/core/adt/fields.go
Expand Up @@ -1012,6 +1012,9 @@ func (ctx *OpContext) notAllowedError(v, arc *Vertex) {
// TODO: setting arc instead of n.node eliminates subfields. This may be
// desirable or not, but it differs, at least from <=v0.6 behavior.
arc.SetValue(ctx, ctx.NewErrf("field not allowed"))
if arc.state != nil {
arc.state.kind = 0
}

// TODO: remove? We are now setting it on both fields, which seems to be
// necessary for now. But we should remove this as it often results in
Expand Down
4 changes: 4 additions & 0 deletions internal/core/adt/tasks.go
Expand Up @@ -318,6 +318,10 @@ func processListVertex(c *OpContext, t *task, mode runMode) {
}

func (n *nodeContext) updateListType(list Expr, id CloseInfo, isClosed bool, ellipsis Node) {
if n.kind == 0 {
n.node.updateStatus(finalized) // TODO(neweval): remove once transitioned.
return
}
m, ok := n.node.BaseValue.(*ListMarker)
if !ok {
m = &ListMarker{
Expand Down

0 comments on commit 709cdc5

Please sign in to comment.