Skip to content

Commit

Permalink
internal/core/adt: fix dropping arcs with double and deep pushdowns
Browse files Browse the repository at this point in the history
Consider this test case:

	if true {
		// order of these two lines matters
		a: b1.b2.b3
		b1: b2: b3: "Foo"
	}

Before, when finalizing a (a pushed down
comprehension), this would cause b1 to
encounter a "pending" arc and yield. As a
result of yielding, though, the pending arcs
would be marked as "not present", causing
a completion of the reference to fail down
the line.

Now, we force recursive evaluation if we
encounter a pending arc.

A fully call-by-need evaluation would probably
have prevented this issue.

Note that this also improves a test in
freeze.txtar. Previously an incomplete error
was reported, but this would be valid on
a call-by-need approach and in general is
solvable.

Fixes #3621

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I2e8e59831594a9462089af0ecd17ab8a8b72d234
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206325
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
  • Loading branch information
mpvl committed Dec 24, 2024
1 parent 4a76cb8 commit c905888
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 214 deletions.
120 changes: 23 additions & 97 deletions cue/testdata/comprehensions/pushdown.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -1549,44 +1549,41 @@ Result:
}
issue3621: (struct){
reduced: (struct){
t1: (_|_){
// [incomplete] issue3621.reduced.t1.b1.b2.b3: cyclic reference to field b2:
// ./issue3621.cue:5:2
a: (_|_){
// [incomplete] issue3621.reduced.t1.a: undefined field: b1:
// ./issue3621.cue:6:6
t1: (struct){
a: (string){ "Foo" }
b1: (struct){
b2: (struct){
b3: (string){ "Foo" }
}
}
}
t2: (_|_){
// [incomplete] issue3621.reduced.t2.inner.inner2.name: cyclic reference to field inner2:
// ./issue3621.cue:12:2
t2: (struct){
outer: (struct){
b: (_|_){
// [incomplete] issue3621.reduced.t2.outer.b: undefined field: inner:
// ./issue3621.cue:14:13
b: (string){ "Foo" }
}
inner: (struct){
inner2: (struct){
name: (string){ "Foo" }
}
}
}
}
full: (_|_){
// [incomplete] issue3621.full.inner.inner2.create_default: cyclic reference to field inner2:
// ./issue3621.cue:20:2
// issue3621.full.inner.inner2.description: cyclic reference to field inner2:
// ./issue3621.cue:20:2
// issue3621.full.inner.inner2.name: cyclic reference to field inner2:
// ./issue3621.cue:20:2
// issue3621.full.inner.inner2.privacy: cyclic reference to field inner2:
// ./issue3621.cue:20:2
full: (struct){
hello: (string){ "world" }
outer: (struct){
outer2: (struct){
bar: (_|_){
// [incomplete] issue3621.full.outer.outer2.bar: undefined field: inner:
// ./issue3621.cue:28:10
}
bar: (string){ "Employees" }
name: (string){ "outer2" }
}
}
inner: (struct){
inner2: (struct){
name: (string){ "Employees" }
description: (string){ "All employees" }
privacy: (string){ "secret" }
create_default: (bool){ false }
}
}
}
}
unifyDynamicReflectSuccess: (struct){
Expand Down Expand Up @@ -1929,7 +1926,7 @@ diff old new
}
}
}
@@ -738,50 +671,53 @@
@@ -738,10 +671,10 @@
}
foo: (#struct){
kind: (string){ "foo" }
Expand All @@ -1942,77 +1939,6 @@ diff old new
}
}
}
issue3621: (struct){
reduced: (struct){
- t1: (struct){
- a: (string){ "Foo" }
- b1: (struct){
- b2: (struct){
- b3: (string){ "Foo" }
- }
- }
- }
- t2: (struct){
+ t1: (_|_){
+ // [incomplete] issue3621.reduced.t1.b1.b2.b3: cyclic reference to field b2:
+ // ./issue3621.cue:5:2
+ a: (_|_){
+ // [incomplete] issue3621.reduced.t1.a: undefined field: b1:
+ // ./issue3621.cue:6:6
+ }
+ }
+ t2: (_|_){
+ // [incomplete] issue3621.reduced.t2.inner.inner2.name: cyclic reference to field inner2:
+ // ./issue3621.cue:12:2
outer: (struct){
- b: (string){ "Foo" }
- }
- inner: (struct){
- inner2: (struct){
- name: (string){ "Foo" }
- }
- }
- }
- }
- full: (struct){
+ b: (_|_){
+ // [incomplete] issue3621.reduced.t2.outer.b: undefined field: inner:
+ // ./issue3621.cue:14:13
+ }
+ }
+ }
+ }
+ full: (_|_){
+ // [incomplete] issue3621.full.inner.inner2.create_default: cyclic reference to field inner2:
+ // ./issue3621.cue:20:2
+ // issue3621.full.inner.inner2.description: cyclic reference to field inner2:
+ // ./issue3621.cue:20:2
+ // issue3621.full.inner.inner2.name: cyclic reference to field inner2:
+ // ./issue3621.cue:20:2
+ // issue3621.full.inner.inner2.privacy: cyclic reference to field inner2:
+ // ./issue3621.cue:20:2
hello: (string){ "world" }
outer: (struct){
outer2: (struct){
- bar: (string){ "Employees" }
+ bar: (_|_){
+ // [incomplete] issue3621.full.outer.outer2.bar: undefined field: inner:
+ // ./issue3621.cue:28:10
+ }
name: (string){ "outer2" }
}
}
- inner: (struct){
- inner2: (struct){
- name: (string){ "Employees" }
- description: (string){ "All employees" }
- privacy: (string){ "secret" }
- create_default: (bool){ false }
- }
- }
}
}
unifyDynamicReflectSuccess: (struct){
-- diff/-out/evalalpha/stats<==>+out/eval/stats --
diff old new
--- old
Expand Down
Loading

0 comments on commit c905888

Please sign in to comment.