There were a couples places where we failed to provide a reasonable
variable environment for YAML encoding. I think this only affects
encoding "!repeat" nodes, which aren't common in practice and a bit of
a disaster, which is how this went unnoticed.
Change-Id: I1a37c00d5eaa1ee8e86d119a2fd73f6a28d69008
Reviewed-on: https://go-review.googlesource.com/c/go/+/698115
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
return
}
+ t.enc.e = e // Interpret values w.r.t. e
t.logf("Unify\n%s\nwith\n%s\nin\n%s",
yamlf(" ", t.enc.value(v)),
yamlf(" ", t.enc.value(w)),
yamlf(" ", t.enc.env(e)))
+ t.enc.e = envSet{}
if t.saveTree {
if t.node == nil {
// Undo any effects on the environment. We *do* keep any named
// variables that were added to the vars map in case they were
// introduced within the element.
+ //
+ // TODO: If we change how we implement repeat nodes, we might be
+ // able to drop yamlEncoder.env and yamlDecoder.env.
dec.env = origEnv
// Add a generator function
gen = append(gen, func(e envSet) (*Value, envSet) {
}
func (v *Value) MarshalYAML() (any, error) {
- enc := &yamlEncoder{}
+ enc := &yamlEncoder{e: topEnv}
return enc.value(v), nil
}