Skip to content

Highlight the Go predeclared types any and comparable - #6011

Merged
nightwing merged 2 commits into
ajaxorg:masterfrom
yu2971512385-ui:fix/golang-predeclared-identifiers
Oct 14, 2026
Merged

nightwing merged 2 commits into
ajaxorg:masterfrom
yu2971512385-ui:fix/golang-predeclared-identifiers

Conversation

@yu2971512385-ui

@yu2971512385-ui yu2971512385-ui commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Issue #, if available: n/a

Description of changes:

golang_highlight_rules.js lists Go's predeclared identifiers as builtinTypes, but not the two the language gained in 1.18 with generics, so they are lexed as ordinary identifiers while error, string and the rest are types:

line before after
var x any any → identifier support.type
type S[E comparable] int comparable → identifier support.type

Tests: a new case in src/mode/golang_test.js asserts both, plus error as a control. It fails on master ('support.type' == 'identifier') and passes with the change; mocha "./src/mode/*_test.js" is green (81 passing, 1 pending).

Correction to the original version of this PR: it also added clear, max and min to builtinFunctions and claimed they were unstyled. That was wrong — the mode already scopes any identifier followed by ( as support.function, so those three are styled at every call site today. The only thing the addition changed was their appearance outside call position, where they are shadowable identifiers, so I removed that part and narrowed this to the two types.

Found by lexing modern-language snippets and flagging identifiers that stay unstyled. AI assistance (Claude) was used for that search and for drafting; I reviewed and tested every line, and the correction above came out of re-verifying the before/after behaviour against a pristine checkout.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Pull Request Checklist:

  • No backwards incompatible changes were made to Ace's public interface
  • Tests added/updated

🤖 Generated with Claude Code

Open kitchen-sink @ e690c632c99727a996d5d4965ea9cfc7ec23453b

yu2971512385-ui and others added 2 commits September 30, 2026 12:01
…and min

The Go mode lists the predeclared types (error, rune, string, ...) and
functions (append, len, make, ...), but not the identifiers the language
gained later: any and comparable (Go 1.18, with generics) and clear, max
and min (Go 1.21).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
clear, max and min are already scoped as support.function wherever they
are called, because the mode scopes any identifier followed by "(" that
way. Adding them to builtinFunctions only changes how they look outside
call position, where they are ordinary identifiers that a program may
well have shadowed, so leave that alone and keep this change to the two
predeclared types.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@yu2971512385-ui yu2971512385-ui changed the title Highlight the Go predeclared identifiers any, comparable, clear, max and min Highlight the Go predeclared types any and comparable Sep 30, 2026
@yu2971512385-ui

Copy link
Copy Markdown
Contributor Author

Correction to my own PR: I narrowed it to any and comparable and dropped clear/max/min.

Re-checking against a pristine master showed those three are already scoped, because line 65 of the mode scopes any identifier followed by ( as support.function — foo(1) behaves the same way. Adding them to builtinFunctions only affected them outside call position (f := min), where they are shadowable identifiers, so the addition was not worth the regression risk. The before/after table in the description is updated accordingly.

Sorry for the noise; the two types are unaffected by that rule and remain a real gap.

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.89%. Comparing base (62d5ffd) to head (e690c63).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6011      +/-   ##
==========================================
- Coverage   93.92%   93.89%   -0.03%     
==========================================
  Files         647      647              
  Lines      140792   140802      +10     
  Branches    14784    14758      -26     
==========================================
- Hits       132237   132206      -31     
- Misses       8555     8596      +41     
Flag Coverage Δ
unittests 93.89% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nightwing
nightwing merged commit bb95957 into ajaxorg:master Oct 14, 2026
3 of 4 checks passed
@nightwing

Copy link
Copy Markdown
Member

Thank you

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.

2 participants