8000 Elision: match 1 or more returned types · Issue #82 · uber-go/gopatch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Elision: match 1 or more returned types #82
Open
@blampe

Description

@blampe

(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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0