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

interp: create real recursive types with unsafe type swapping #1236

Merged
merged 7 commits into from
Aug 30, 2021

Conversation

nrwiersma
Copy link
Contributor

As the unsafe and pointer methods in reflect are to be depreciated, and seeing no replacement functions, it is now forced that some unsafe is needed to replace this as when and interface is dereferenced it is made unsettable by reflect.

With this in mind, this adds real recursive types by hot swapping the struct field type on the fly. This removes a lot of compensation code, simplifying all previous cases.

Note: While the struct field type is swapped for the real type, the type string is not changed. Due to this, unsafe will recreate the same type.

interp/type.go Outdated Show resolved Hide resolved
nrwiersma and others added 2 commits August 30, 2021 14:17
@mvertes
Copy link
Member

mvertes commented Aug 30, 2021

The following test, ok with v0.9.23, fails here with a panic, but also probably since #1231.

package main

func main() {
    b := []byte{1, 3, 50}
    w := uint32(b[1])
    println(w)
}   

// Output:
// 3

@mvertes
Copy link
Member

mvertes commented Aug 30, 2021

The test is above is in fact ok. Sorry for the noise

Copy link
Member

@mvertes mvertes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mvertes mvertes added bug Something isn't working status/3-needs-merge and removed bug Something isn't working labels Aug 30, 2021
@traefiker traefiker merged commit 4af992b into traefik:master Aug 30, 2021
@nrwiersma nrwiersma deleted the recursive branch August 30, 2021 17:29
mvertes added a commit that referenced this pull request Sep 8, 2021
Make sure to keep always a single copy of incomplete type structures.
Remove remnants of recursive types processing.

Now `import "go.uber.org/zap"` works again (see #1172), fixing regressions
introduced by #1236.
traefiker pushed a commit that referenced this pull request Sep 13, 2021
Make sure to keep always a single copy of incomplete type structures.
Remove remnants of recursive types processing.

Now `import "go.uber.org/zap"` works again (see #1172), fixing regressions
introduced by #1236.
traefiker pushed a commit that referenced this pull request Sep 13, 2021
Make sure to keep always a single copy of incomplete type structures.
Remove remnants of recursive types processing.

Now `import "go.uber.org/zap"` works again (see #1172), fixing regressions
introduced since #1236.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants