traefik/yaegi

Embedding of 'Anonymous' structs is broken

connor-strata opened this issue · 0 comments

The following program sample.go triggers an unexpected result

package main

import (
	"encoding/json"
	"fmt"
)

type Outer struct {
	Inner
	Val string `json:"val"`
}

type Inner struct {
	Secret string `json:"secret"`
}

func main() {
	obj := Outer{
		Inner: Inner{
			Secret: "secret-string",
		},
		Val: "value-string",
	}

	bs, _ := json.Marshal(obj)

	fmt.Println(string(bs))
}

Expected result

{"secret":"secret-string","val":"value-string"}

Got

{"Inner":{"secret":"secret-string"},"val":"value-string"}

Yaegi Version

v0.16.0

Additional Notes

This behavior changed between v0.15.1 and v0.16.0 by this commit (line).