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

x/tools/gopls: support fillstruct for "anonymous struct" struct fields #39929

Closed
joshbaum opened this issue Jun 29, 2020 · 2 comments
Closed

x/tools/gopls: support fillstruct for "anonymous struct" struct fields #39929

joshbaum opened this issue Jun 29, 2020 · 2 comments

Comments

@joshbaum
Copy link

@joshbaum joshbaum commented Jun 29, 2020

The fix needs to be made at this TODO in the analysisinternal package.

Edited by @stamblerre to add an example. Consider the following struct definition and literal.

package main

type Foo struct {
    Bar struct { Baz int }
}

func main() {
    foo := Foo{<>}
}

Expected:

package main

type Foo struct {
    Bar struct { Baz int }
}

func main() {
    foo := Foo{
        Bar: struct { Baz int }{
            Baz: 0,
        },
    }
}

Currently, fillstruct will not even be suggested for the Foo literal. This can be fixed by addressing the TODO linked above.

@gopherbot gopherbot added this to the Unreleased milestone Jun 29, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 29, 2020

Change https://golang.org/cl/240463 mentions this issue: internal/lsp/analysis/fillstruct: permit anonymous structs to be filled

@stamblerre stamblerre removed this from the Unreleased milestone Jul 2, 2020
@stamblerre stamblerre added this to the gopls/v0.5.0 milestone Jul 2, 2020
gopherbot pushed a commit to golang/tools that referenced this issue Jul 7, 2020
The previous implementation did not support filling anonymous structs.
This is distinct from filling a struct that has an anonymous
struct as a field. That field will still not be filled.
golang/go#39929 has been opened to address this limitation.

Fixes: golang/go#39803
Change-Id: Ia7ba9fda2bdee092d182e0a23829b9a6d9a4b986
Reviewed-on: https://go-review.googlesource.com/c/tools/+/240463
Run-TryBot: Josh Baum <joshbaum@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
@stamblerre stamblerre closed this Jul 8, 2020
@stamblerre stamblerre removed this from the gopls/v0.5.0 milestone Jul 9, 2020
@stamblerre stamblerre added this to the gopls/v0.4.4 milestone Jul 9, 2020
@stamblerre stamblerre reopened this Jul 9, 2020
@golang golang deleted a comment from gopherbot Jul 10, 2020
@stamblerre stamblerre removed this from the gopls/v0.4.4 milestone Jul 12, 2020
@stamblerre stamblerre added this to the gopls/v0.5.0 milestone Jul 12, 2020
@stamblerre stamblerre removed this from the gopls/v0.5.0 milestone Jul 21, 2020
@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Jul 23, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Aug 26, 2020

@stamblerre stamblerre closed this Aug 26, 2020
@stamblerre stamblerre removed this from the gopls/v1.0.0 milestone Aug 26, 2020
@stamblerre stamblerre added this to the gopls/v.0.5.0 milestone Aug 26, 2020
@golang golang locked and limited conversation to collaborators Aug 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants