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
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@joshbaum
Copy link

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 Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 29, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 29, 2020
@gopherbot
Copy link

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

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 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 modified the milestones: gopls/v0.5.0, gopls/v0.4.4 Jul 9, 2020
@stamblerre stamblerre reopened this Jul 9, 2020
@golang golang deleted a comment from gopherbot Jul 10, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.4.4, gopls/v0.5.0 Jul 12, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v1.0.0 Jul 21, 2020
@stamblerre
Copy link
Contributor

Fixed in https://golang.org/cl/249999.

@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.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants