Repository navigation
[Go] Scope the built-in functions clear, max and min - #4620
Merged
deathaxe merged 1 commit intoSep 30, 2026
Merged
Conversation
Go 1.21 added clear, max and min to the predeclared identifiers, but predeclared_func still stops at Go 1.20, so calls to them are scoped as plain functions while append, len and the rest are marked as built-ins. The predeclared types already cover any and comparable, so this brings the function list to the same version of the language. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jrappen
approved these changes
Sep 30, 2026
deathaxe
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
predeclared_funclists Go's built-in functions up to Go 1.20. Go 1.21 added three more —clear,maxandmin— so calls to them are scoped as ordinary functions whileappend,len,deleteand the rest getsupport.function.builtin.go:predeclared_typeis already current for Go 1.18 (it hasanyandcomparable), so this just brings the function list to the same version of the language.Since the rule only matches a predeclared name that is directly followed by a call's
(, shadowed uses such asmin := 0orvar max intkeep their ordinary scope, exactly as for the names already in the list.Syntax tests were added under "Other Functions" alongside the existing
closecases (including a bareminto check the call-only behaviour). I could not run Sublime's syntax test runner locally, so the assertions mirror the existingclose(ident)block exactly and I verified the caret columns line up with the code above them; CI will confirm.AI assistance (Claude) was used to find this gap — by lexing modern Go and looking for predeclared identifiers that stay unscoped — and to draft this description. I reviewed every line.
🤖 Generated with Claude Code