Skip to content

Conversation

Afterous
Copy link
Contributor

@Afterous Afterous commented Sep 22, 2024

Hello,
This will fix a panic when you run go critic with hugeParam and scan a function that is named String, but does not return any value.

The document state the Results could be nil, this change will check for the nil before checking the length.
https://pkg.go.dev/go/ast#FuncType

Please let me know if you need me to write a test or fix anything else.

Thank you again for writing this tool!

example code that when ran with ./gocritic check -enable=hugeParam will panic

package main

type foo struct {}

func (foo) String() {
  // Empty
}

func main() {
  f := foo{}
  f.String()
}

@Afterous Afterous changed the title fix: ast.FuncDecl.Type.Results could be nil. checkers/hugeParam: fix: ast.FuncDecl.Type.Results could be nil when checking for String() Sep 22, 2024
@Afterous
Copy link
Contributor Author

Afterous commented Oct 9, 2024

@cristaloleg what steps would I need to complete to get this merged into the master branch?

@cristaloleg cristaloleg merged commit 33c243b into go-critic:master Oct 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants