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

Request: treat min, max and clear as built-in functions #1021

Closed
skaji opened this issue Aug 10, 2024 · 1 comment · Fixed by #1024
Closed

Request: treat min, max and clear as built-in functions #1021

skaji opened this issue Aug 10, 2024 · 1 comment · Fixed by #1024

Comments

@skaji
Copy link
Contributor

skaji commented Aug 10, 2024

Is your feature request related to a problem? Please describe.

go 1.21 has introduced new functions min, max and clear.
https://go.dev/ref/spec#Go_1.21

Currently revive does not treat min, max and clear as built-in functions,
https://github.com/mgechev/revive/blob/master/rule/redefines-builtin-id.go#L18-L34
so it does not report redefinition of the built-in function error.

// Reproduce issue
package main

import "fmt"

func main() {
	min := 0
	fmt.Println(min)
}
❯ revive -set_exit_status ./...

❯ echo $?
0

Describe the solution you'd like

revive treats min, max and clear as built-in functions on go 1.21+,
and reports the following error:

main.go: redefinition of the built-in function min

Describe alternatives you've considered

There may be an option not to make changes in order to maintain backward compatibility.

Additional context

NA

@chavacava
Copy link
Collaborator

Hi @skaji thanks for reporting this issue
Since a few weeks there is a function Pkg.IsAtLeastGo122() that can be useful when implementing the feature you request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants