Repository navigation
enh(go) add the predeclared identifiers any, comparable, min, max and clear - #4553
Open
yu2971512385-ui wants to merge 1 commit into
Open
yu2971512385-ui wants to merge 1 commit into
yu2971512385-ui wants to merge 1 commit into
Conversation
… clear The type list already carries the predeclared types (bool, byte, error, string, ...) but not any and comparable, which Go 1.18 added along with generics, and the built-in list predates the clear, max and min functions of Go 1.21. All five are predeclared identifiers in the language spec, like the entries already in those lists. Assisted-by: Claude Opus 5 (high) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
nexoracontrol-ops
approved these changes
Oct 5, 2026
This branch has not been deployed
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.
Changes
The Go grammar's
TYPESlist carries the predeclared types (bool,byte,error,string, …) but notanyandcomparable, which Go 1.18 added alongside generics, andBUILT_INSpredatesclear,maxandminfrom Go 1.21. All five are predeclared identifiers in the spec, exactly like the entries already in those two lists (which are likewise shadowable —len,copy,new,delete).Before → after on ordinary modern Go:
var data map[string]anyanyunstyledhljs-typefunc process(in any) anyanyunstyledhljs-typetype Set[E comparable] map[E]struct{}comparableunstyledhljs-typelo := min(1, 2)minunstyledhljs-built_inclear(data)clearunstyledhljs-built_inNote the type parameter list of a function declaration (
func Index[E comparable](…)) is consumed by the existing function/title mode and is unaffected by this change; that is a separate pre-existing quirk and I left it alone to keep this focused.Checklist
test/markup/go/predeclared-identifiers.txt) — it fails onmainand passes with the change;mocha testis green (1651 passing, 3 pending),npm run lint-languagesclean.Assisted-by: Claude Opus 5 (high)and I reviewed and tested every line.🤖 Generated with Claude Code