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

Elision: match 1 or more returned types #82

Open
blampe opened this issue Oct 26, 2022 · 0 comments
Open

Elision: match 1 or more returned types #82

blampe opened this issue Oct 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@blampe
Copy link

blampe commented Oct 26, 2022

(Edit: the below is using 10bff91)

This patch

@@
@@
 func f() (...) {
- fmt.Println("")
+ fmt.Println("hello")
  ...
 }

will match against

package foo

func f() (string, error) {
  fmt.Println("")
  return "", nil
}

but not

package foo

func f() string {
  fmt.Println("")
  return ""
}

I thought the parentheses were forcing more than one return type, so I tried patching without them

@@
@@
 func f() ... {
- return ""
+ return "hello"
 }

however this is not a valid patch:

load patch "repro": parse: repro/0.minus:1:11: found unexpected "..." inside *ast.FieldList

This isn't a big deal -- I can repeat the patch for 1 return type and N return types.

Intuitively, I would have thought "(...)" already represents "zero to N" return types, although I could also be totally misunderstanding the syntax!

@blampe blampe changed the title Elision: match 0 returned types Elision: match 1 or more returned types Oct 26, 2022
@abhinav abhinav added the bug Something isn't working label Oct 26, 2022
lverma14 added a commit to lverma14/gopatch that referenced this issue Aug 21, 2023
lverma14 added a commit to lverma14/gopatch that referenced this issue Aug 21, 2023
lverma14 added a commit to lverma14/gopatch that referenced this issue Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants