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

go/ast: add func Unparen(Expr) Expr #60061

Closed
adonovan opened this issue May 8, 2023 · 4 comments
Closed

go/ast: add func Unparen(Expr) Expr #60061

adonovan opened this issue May 8, 2023 · 4 comments

Comments

@adonovan
Copy link
Member

adonovan commented May 8, 2023

Almost every application that uses go/ast needs a function to strip parens. There are 4 copies of unparen in the standard library. golang.org/x/tools has astutil.Unparen. I propose we add this function to go/ast.

package ast // import "go/ast"

// Unparen returns e with any enclosing parentheses stripped.
func Unparen(e Expr) Expr

See https://go.dev/cl/495315 for the implementation.

@adonovan adonovan added this to the Proposal milestone May 8, 2023
@ianlancetaylor ianlancetaylor changed the title go/ast: add 'func Unparen(Expr) Expr' proposal: go/ast: add 'func Unparen(Expr) Expr' May 9, 2023
@gopherbot
Copy link

Change https://go.dev/cl/495315 mentions this issue: go/ast: add Unparen(Expr) helper

@rsc
Copy link
Contributor

rsc commented May 17, 2023

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

@rsc
Copy link
Contributor

rsc commented May 24, 2023

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

@rsc rsc changed the title proposal: go/ast: add 'func Unparen(Expr) Expr' go/ast: add 'func Unparen(Expr) Expr' May 24, 2023
@rsc rsc modified the milestones: Proposal, Backlog May 24, 2023
@rsc rsc changed the title go/ast: add 'func Unparen(Expr) Expr' go/ast: add func Unparen(Expr) Expr May 24, 2023
@gopherbot
Copy link

Change https://go.dev/cl/548882 mentions this issue: doc/go1.22: document ast.Unparen

gopherbot pushed a commit that referenced this issue Dec 12, 2023
Updates #60061

Change-Id: Ifa51f0bac0346ebc352c7524204aa94336a2b5ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/548882
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
Updates golang#60061

Change-Id: Ifa51f0bac0346ebc352c7524204aa94336a2b5ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/548882
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Accepted
Development

No branches or pull requests

3 participants