this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/dep: always introduce Environment for Comprehension Value to fix panic

Comprehension conjuncts need an extra wrapping of
an Evaluator to account for the Comprehenion's Value clauses.
The dep package creates its own Evaluator. But for Comprehensions
that get "pushed down" (in case of a fixed field), markExpr would
discard the Comprehension and mark references in the Value before
the Value was actually unwrapped. This has now been fixed.

This introduces some more reporting of "inner" dependencies
(msg => msg, in this case), which is a known problem that should
be solved in another CL.

Fixes #2512

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: If28f59fccf6f8dbe7e81a132607b542af737044b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/557517
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>

authored by

Marcel van Lohuizen and committed by
Daniel Martí
99e8578a 97d7109d

+16 -1
+3 -1
internal/core/dep/dep.go
··· 486 486 // markConjuncts transitively marks all reference of the current node. 487 487 func (c *visitor) markConjuncts(v *adt.Vertex) { 488 488 for _, x := range v.Conjuncts { 489 - c.markExpr(x.Env, x.Expr()) 489 + // Use Elem instead of Expr to preserve the Comprehension to, in turn, 490 + // ensure an Environment is inserted for the Value clause. 491 + c.markExpr(x.Env, x.Elem()) 490 492 } 491 493 } 492 494
+11
internal/core/dep/testdata/inline.txtar
··· 108 108 } 109 109 #g: result: strings.Join(strings.Split("foo.bar", ""), ".") 110 110 111 + a: issue2512: (extIf & {}).env 112 + extIf: { 113 + if true { 114 + env: msg 115 + } 116 + } 117 + 111 118 -- out/dependencies/field -- 112 119 line reference path of resulting vertex 113 120 -- out/dependencies/all -- ··· 137 144 108: strings.Join => "strings".Join 138 145 108: strings.Split => "strings".Split 139 146 93: (#g & {arg: runs.t1.stdout + runs.t2.stdout}).result => #g.result 147 + 113: msg => msg 148 + 110: (extIf & {}).env => extIf.env 140 149 -- out/dependencies/dynamic -- 141 150 line reference path of resulting vertex 142 151 8: [c][0] => a.b.c ··· 176 185 108: strings.Join => "strings".Join 177 186 108: strings.Split => "strings".Split 178 187 93: (#g & {arg: runs.t1.stdout + runs.t2.stdout}).result => #g.result 188 + 113: msg => msg 189 + 110: (extIf & {}).env => extIf.env
+2
internal/core/dep/testdata/selfref.txtar
··· 30 30 4: outer => outer 31 31 -- out/dependencies/dynamic -- 32 32 line reference path of resulting vertex 33 + 14: X.enabled => a.instance.enabled 34 + 4: outer => outer 33 35 4: (instance & outer & {enabled: true}).value => a.instance.value 34 36 4: outer => outer 35 37 5: val => a.command.alias.val