Skip to content

[Go] Scope the built-in functions clear, max and min - #4620

Merged
deathaxe merged 1 commit into
sublimehq:masterfrom
yu2971512385-ui:go-builtin-clear-max-min
Sep 30, 2026
Merged

deathaxe merged 1 commit into
sublimehq:masterfrom
yu2971512385-ui:go-builtin-clear-max-min

Conversation

@yu2971512385-ui

Copy link
Copy Markdown

predeclared_func lists Go's built-in functions up to Go 1.20. Go 1.21 added three more — clear, max and min — so calls to them are scoped as ordinary functions while append, len, delete and the rest get support.function.builtin.go:

    clear(m)   // variable.function.go        (before)
    close(c)   // variable.function.go support.function.builtin.go

predeclared_type is already current for Go 1.18 (it has any and comparable), 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 as min := 0 or var max int keep their ordinary scope, exactly as for the names already in the list.

Syntax tests were added under "Other Functions" alongside the existing close cases (including a bare min to check the call-only behaviour). I could not run Sublime's syntax test runner locally, so the assertions mirror the existing close(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

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>
@deathaxe
deathaxe merged commit cbac170 into sublimehq:master Sep 30, 2026
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.

3 participants