Repository navigation
fix(lint)!: prefix option constructors to avoid Base collisions - #1565
Merged
Lorenzobattistela merged 2 commits intoOct 15, 2026
Merged
Conversation
Use OptionText in the Bend option contract and its JS bridge so Bend-written rules load with Base's Text event constructor. BREAKING CHANGE: direct Lint.Text constructor users must use Lint.OptionText. Option helpers and configuration are unchanged.
nicolas-abril
left a comment
Collaborator
There was a problem hiding this comment.
AI review (Claude Code), posted by @nicolas-abril.
No bugs in the diff itself: at 645d9e29 no Text constructor reference is left in tools/bend-lint, and Base and bend-lint now share no constructor names except Base's own Some and None. The rest is about how this can happen again, and what fails silently.
In this PR
- The rename needs a migration note in the README (
lint.bend:34). It breaks user rules: one matchingcase Some{Lint.Text{t}}now fails with an unknown-constructor error, and one matching a bareText{t}now binds to Base'sEvent.Textand fails with a type error. Neither error points at the rename, and the compatibility note is only in the PR body, not intools/bend-lint/README.md's rule-authoring section. - The
Valueconstructors are named inconsistently (lint.bend:32):Num,Flag,OptionText.NumandFlagare generic enough that Base could add them too, which would repeat this outage. Renaming all three the same way (OptionNum,OptionFlag,OptionText) in this breaking change costs no extra compatibility.
Outside this PR (follow-ups)
- No gate runs bend-lint's tests (
repo-gate.yml:37). Onlygates/repo.tsruns on PRs, which is how #1441 merged while breaking bend-lint. Main atdbb3157already shows 109 pass / 9 fail / 1 error underbun testintools/bend-lint. - The root cause is still there (
bend.ts:2425).parse_freshrejects a module-local name whose bare form is already declared, so a module can't reuse a name Base defines.lint.bendstill declares about 30 bare constructors (Num,Flag,Span,Edit,Fix,Error,Warning,Hint,Node,Term,Option,Use,View,Shape, …). Base adding any of them givesduplicate declarationand stops bend-lint and every Bend rule from loading. Letting a namespaced declaration shadow Base's bare name, or namespacing Base, would fix the whole class. (bend.tsis human-written perAGENTS.md.) - A stale bridge tag binds silently (
comp.ts:2789).c_idsresolvesCID(k)in the source's namespace first, then falls back to the barek. Foreign JS still usingCID(Text)after this rename resolves toEvent.Textinstead of failing to compile. The rule gets a tag nooption_*_orarm expects, so string options quietly come back as their default (thenoneinstead ofxthis PR ran into).
Suggest fixing 1 and 2 here, and opening issues for 3 to 5.
Use OptionNum and OptionFlag alongside OptionText, and document direct constructor and foreign CID migration for rule authors. BREAKING CHANGE: direct Lint.Num and Lint.Flag users must use Lint.OptionNum and Lint.OptionFlag. Option helpers and configuration are unchanged.
Lorenzobattistela
approved these changes
Oct 15, 2026
Merged
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.
Problem and fix
Base's
Textconstructor forEvent, added in #1441, collides with bend-lint's text option constructor. Bend-written rules, including the bundled file-length rule, fail to load withduplicate declaration: Text.Use consistent
OptionNum,OptionFlag, andOptionTextnames for the three option constructors, their helper match arms, and their JavaScript bridge tags. Document the constructor migration in the README's rule-authoring section.Blast radius
tools/bend-lint/src/bend/lint.bend: three option constructors and nine helper match arms.tools/bend-lint/src/bend/effects.js: the tags used to send number, boolean, and string options to Bend rules.tools/bend-lint/README.md: migration guidance for rule authors.Compatibility impact: direct construction or matching of
Lint.Num,Lint.Flag, andLint.Textmust useLint.OptionNum,Lint.OptionFlag, andLint.OptionText. Bare constructor names and handwritten foreignCID(...)references also need updating. Documented option helpers, JSON configuration, and TypeScript option APIs retain their behavior; bundled rules use the helpers.The compiler, Base, formatter, and gates are unchanged. Existing tests stay in bend-lint's suite, following the maintainer guidance in #1389.
Regression evidence
The existing
a Bend rule reads its options with defaultstest compiles the actual contract and executes the JS bridge with number, boolean, and string options. It fails on basedbb3157at the duplicate declaration and passes with this fix. Restoring only the oldCID(Text)bridge tag in the final source makes that same test lose the configured string (noneinstead ofx), so it also detects an incomplete rename. No additional test is needed.Clean base's tool suite reports
109 pass / 9 fail / 1 error; the fixed suite reports122 pass / 0 fail. The file-length test module now loads and its tests register.Checks
bun testintools/bend-lint: 122 passed, 0 failed; 700 assertions.bun gates/repo.ts: 54/54, with CI-pinned ttok 0.3.maxLines: 1, and exits 0.git diff --check: passed.Validation limits
Local checks ran on macOS arm64 with Bun 1.3.11. Windows, the cluster gates, and typecheck were not run. External third-party rules and alternative Bend releases were not tested; direct constructor consumers require the migration described above. Other bare tool constructor names remain subject to collisions with future Base additions; this change only updates the option constructors.