Skip to content

enh(go) add min, max, and clear built-in functions (Go 1.21) - #4528

Open
dylanpulver wants to merge 1 commit into
highlightjs:mainfrom
dylanpulver:go-builtins-min-max-clear
Open

enh(go) add min, max, and clear built-in functions (Go 1.21)#4528
dylanpulver wants to merge 1 commit into
highlightjs:mainfrom
dylanpulver:go-builtins-min-max-clear

Conversation

@dylanpulver

@dylanpulver dylanpulver commented Sep 1, 2026

Copy link
Copy Markdown

Changes

src/languages/go.js's BUILT_INS list is missing the three built-in functions Go added in 1.21 (Aug 2023): clear, max, and min. The Go spec's "Built-in functions" section lists all of append, cap, clear, close, complex, copy, delete, imag, len, make, max, min, new, panic, print, println, real, recover; the grammar has every one except those three.

Effect on current mainmin, max, clear are highlighted as plain identifiers, while len/append (also predeclared, and already in the list) get built_in:

clear(s)          // not highlighted
lo := min(1, 2)   // not highlighted
n  := len(s)      // hljs-built_in  (control)

Fix adds the three names to BUILT_INS, in their alphabetical slots. They're predeclared identifiers (shadowable), exactly like the len/cap/append entries already treated as built_in, so this is consistent with existing behaviour.

Added a test/markup/go/builtins fixture covering the three new builtins plus len/append as controls; it fails on main (only clear/min/max differ) and passes with the change. Full go markup suite green, lint-languages clean.

Checklist

  • Added markup tests, or they don't apply here because...
  • I have read and followed our AI-assisted contributions policy (human review, no slop)

Assisted-by: Claude Opus 5 (high)

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.

1 participant