Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

compiler/natives/src/reflect: fix valueIntrface check struct copy #1157

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

Merged
merged 4 commits into from
Sep 29, 2022

Conversation

visualfc
Copy link
Contributor

fix #1156

@nevkontakte
Copy link
Member

A couple of questions:

  • Should the copy happen when Value.Index() or Value.Interface() method is called? I think in the equivalent non-reflect code the copy would happen on the index operation.
  • Does reflectlite have the same bug? If so, maybe fix it as well?

@visualfc
Copy link
Contributor Author

A couple of questions:

  • Should the copy happen when Value.Index() or Value.Interface() method is called? I think in the equivalent non-reflect code the copy would happen on the index operation.

copy struct on reflect.Value to interface time.
v.Index(0) == a[0]

	a := []student{student{"A"}, student{"B"}, student{"C"}}
	v := reflect.ValueOf(a)
	i := v.Index(0)
        j := i.Interface()
	a[0] = student{"X"}
	fmt.Println(a, i, j)
        // output [{X} {B} {C}] {X} {A}
  • Does reflectlite have the same bug? If so, maybe fix it as well?

sync with reflect

tests/copy_test.go Outdated Show resolved Hide resolved
@nevkontakte nevkontakte merged commit 5214468 into gopherjs:master Sep 29, 2022
@nevkontakte
Copy link
Member

Thank you for your contribution!

@visualfc visualfc deleted the valueinterface branch September 29, 2022 23:49
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

Successfully merging this pull request may close these issues.

reflect value.Interface not copy for struct
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.