mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.simd] simd/_gen/unify: fix some missing environments
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>
This commit is contained in:
parent
7c84e984e6
commit
f7c6fa709e
2 changed files with 6 additions and 1 deletions
|
|
@ -132,10 +132,12 @@ func (t *tracer) traceUnify(v, w *Value, e envSet) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.enc.e = e // Interpret values w.r.t. e
|
||||||
t.logf("Unify\n%s\nwith\n%s\nin\n%s",
|
t.logf("Unify\n%s\nwith\n%s\nin\n%s",
|
||||||
yamlf(" ", t.enc.value(v)),
|
yamlf(" ", t.enc.value(v)),
|
||||||
yamlf(" ", t.enc.value(w)),
|
yamlf(" ", t.enc.value(w)),
|
||||||
yamlf(" ", t.enc.env(e)))
|
yamlf(" ", t.enc.env(e)))
|
||||||
|
t.enc.e = envSet{}
|
||||||
|
|
||||||
if t.saveTree {
|
if t.saveTree {
|
||||||
if t.node == nil {
|
if t.node == nil {
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,9 @@ func (dec *yamlDecoder) value(node *yaml.Node) (vOut *Value, errOut error) {
|
||||||
// Undo any effects on the environment. We *do* keep any named
|
// Undo any effects on the environment. We *do* keep any named
|
||||||
// variables that were added to the vars map in case they were
|
// variables that were added to the vars map in case they were
|
||||||
// introduced within the element.
|
// 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
|
dec.env = origEnv
|
||||||
// Add a generator function
|
// Add a generator function
|
||||||
gen = append(gen, func(e envSet) (*Value, envSet) {
|
gen = append(gen, func(e envSet) (*Value, envSet) {
|
||||||
|
|
@ -444,7 +447,7 @@ func (c Closure) String() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Value) MarshalYAML() (any, error) {
|
func (v *Value) MarshalYAML() (any, error) {
|
||||||
enc := &yamlEncoder{}
|
enc := &yamlEncoder{e: topEnv}
|
||||||
return enc.value(v), nil
|
return enc.value(v), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue