Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding of 'Anonymous' structs is broken #1656

Open
connor-strata opened this issue Aug 28, 2024 · 0 comments
Open

Embedding of 'Anonymous' structs is broken #1656

connor-strata opened this issue Aug 28, 2024 · 0 comments

Comments

@connor-strata
Copy link

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).

@connor-strata connor-strata changed the title Allow structs to have multiple embedded 'Anonymous' structs when only the first has methods Embedding of 'Anonymous' structs is broken Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant