Skip to content

Commit

Permalink
internal/core/dep: dereference non-rooted values
Browse files Browse the repository at this point in the history
With the implementation of the new evaluator, especially
with structure sharing, it is often no longer correct
to dereference a Vertex unconditionally. So the new
evaluator removed some dereferences, sometimes a bit
too aggressively.

This changes patches one of these changes locally.
In a followup CL we provide a more general fix and
remove this change again. This allows us to fall back
on this change if that results in any issues.

Issue #3060

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I755e74f9197ab9d2643f40765d32c94754d0eed2
  • Loading branch information
mpvl committed May 8, 2024
1 parent a8ec4b7 commit eb4afb6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 72 deletions.
2 changes: 1 addition & 1 deletion internal/core/dep/dep.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func (c *visitor) reportDependency(env *adt.Environment, ref adt.Resolver, v *ad
c.numRefs++

d := Dependency{
Node: v,
Node: v.DerefNonRooted(),
Reference: altRef,
pkg: c.pkg,
top: c.top,
Expand Down
20 changes: 1 addition & 19 deletions internal/core/dep/testdata/dynamic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,8 @@ line reference path of resulting vertex
-- out/dependencies/all --
line reference path of resulting vertex
21: middle => middle
-- out/dependencies-v3/dynamic --
line reference path of resulting vertex
21: middle => middle
21: x => **non-rooted**
21: x => **non-rooted**
-- diff/-out/dependencies-v3/dynamic<==>+out/dependencies/dynamic --
diff old new
--- old
+++ new
@@ -1,4 +1,4 @@
line reference path of resulting vertex
21: middle => middle
-21: x => middle.la1
-21: x => middle.la2
+21: x => **non-rooted**
+21: x => **non-rooted**
-- diff/dependencies/todo/p1 --
middle.la*: now replaced with "non-rooted"
-- out/dependencies/dynamic --
line reference path of resulting vertex
21: middle => middle
21: x => middle.la1
21: x => middle.la2
21: x => middle.la2
26 changes: 0 additions & 26 deletions internal/core/dep/testdata/structcomprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,6 @@ line reference path of resulting vertex
5: e => e
5: d => d
8: f.g => f.g
-- out/dependencies-v3/dynamic --
line reference path of resulting vertex
2: c => c
5: e => e
8: f.g => f.g
5: x => **non-rooted**
5: d => d
5: x => **non-rooted**
5: d => d
-- diff/-out/dependencies-v3/dynamic<==>+out/dependencies/dynamic --
diff old new
--- old
+++ new
@@ -2,7 +2,7 @@
2: c => c
5: e => e
8: f.g => f.g
-5: x => c[0]
-5: d => d
-5: x => c[1]
+5: x => **non-rooted**
+5: d => d
+5: x => **non-rooted**
5: d => d
-- diff/dependencies/todo/p1 --
Some values now marked as non-rooted.
-- out/dependencies/dynamic --
line reference path of resulting vertex
2: c => c
Expand Down
42 changes: 16 additions & 26 deletions internal/core/dep/testdata/topcomprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -23,50 +23,40 @@ a: {
}
-- out/dependencies/field --
line reference path of resulting vertex
-- out/dependencies-v3/all --
-- out/dependencies/all --
line reference path of resulting vertex
4: key => **non-rooted**
5: value => **non-rooted**
2: key => **non-rooted**
3: value => **non-rooted**
-- out/dependencies-v3/dynamic --
line reference path of resulting vertex
4: key => **non-rooted**
5: value => **non-rooted**
2: key => **non-rooted**
3: value => **non-rooted**
11: key => **non-rooted**
12: value => **non-rooted**
9: key => **non-rooted**
-- diff/-out/dependencies-v3/all<==>+out/dependencies/all --
diff old new
--- old
+++ new
@@ -2,4 +2,3 @@
4: key => **non-rooted**
5: value => **non-rooted**
2: key => **non-rooted**
-3: value => **non-rooted**
10: value => **non-rooted**
-- diff/-out/dependencies-v3/dynamic<==>+out/dependencies/dynamic --
diff old new
--- old
+++ new
@@ -1,9 +1,6 @@
@@ -1,9 +1,9 @@
line reference path of resulting vertex
4: key => **non-rooted**
-5: value => **non-rooted**
+2: key => **non-rooted**
11: key => **non-rooted**
12: value => **non-rooted**
-2: key => **non-rooted**
-3: value => **non-rooted**
5: value => **non-rooted**
-11: key => **non-rooted**
-12: value => **non-rooted**
2: key => **non-rooted**
3: value => **non-rooted**
+11: key => **non-rooted**
+12: value => **non-rooted**
9: key => **non-rooted**
-10: value => **non-rooted**
-- diff/dependencies/todo/p1 --
Missing line items.
-- out/dependencies/all --
line reference path of resulting vertex
4: key => **non-rooted**
5: value => **non-rooted**
2: key => **non-rooted**
3: value => **non-rooted**
10: value => **non-rooted**
-- diff/dependencies/todo/p3 --
Reordering.
-- out/dependencies/dynamic --
line reference path of resulting vertex
4: key => **non-rooted**
Expand Down

0 comments on commit eb4afb6

Please sign in to comment.