Conversation
lexPunctuator() tests '<' and '>' inside a check for "[](){}.,;", and
lexOperator() consumes both characters first. So isInJSXTag,
isJSXTagStart and isInGenericType are never set. The type-reference
test reads the character before the cursor after the identifier is
consumed, and the nextToken() call that sets isAfterExtendsOrImplements
also clears it.
Remove that state, the htmlTags table, the enum members and the CSS
rule that only that state can produce, and the line and column
counters that nothing reads. Also remove highlight() and its helper,
consumeTemplateString(), shouldRedactSensitive(), sensitivePatterns,
three options and a local that nothing uses. syntaxHighlight() returns
the same string for every input.
|
Status: ready for review. The diff is green in CI. The one red job comes from a test that this PR does not touch. CI
How to see the dead state on main
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. WalkthroughThe bake client highlighter removes several JSX and TypeScript tokenization paths, position tracking, sensitive-information redaction, and its multiline renderer. The ChangesJavaScript highlighter
Suggested reviewers: Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is established; the change is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
LGTM — pure dead-code removal in the Bake overlay highlighter; I traced the removed paths and found no output change.
What was reviewed:
- The removed "type reference" heuristic in
lexIdentifierOrKeyword:prevCharis read afterconsumeIdentifier(), which only consumesIDENTIFIER_PARTchars, so it can never be:or<;isAfterExtendsOrImplementsis set and cleared inside the samenextToken()call, so it is always false when read. All four disjuncts were unreachable. - The JSX/generic state in
lexPunctuator: the</>arms sit inside"[](){}.,;".includes(char)andlexOperatorruns first, soisInJSXTag/isInGenericType/htmlTagswere never set or read. - Retained path:
overlay.tsis the only importer and usessyntaxHighlight()->highlightLine(), which is untouched; no remaining references tohighlight(), the deleted options, enum members, or.syntax-redinsrc/runtime/bake/ortest/bake/.
Extended reasoning...
The change deletes 332 lines and adds 1 across src/runtime/bake/client/JavaScriptSyntaxHighlighter.ts and overlay.css, removing unused options, enum members, JSX/generic/destructuring state flags, line/column tracking, the multi-line highlight() method and helpers, and the matching unreferenced CSS rule. It touches no security-sensitive surface; the HTML-escaping in wrap()/escapeHtml() and the retained highlightLine() path are unchanged. I statically verified the one hunk that looked like a behavior change (the type-reference heuristic) is unreachable, so the PR's "no output change" claim holds and no new test is required. The files have no CODEOWNERS entry and the only consumer is overlay.ts, which still compiles against the retained API.
|
Updated 4:22 AM PT - Oct 3rd, 2026
❌ @robobun, your commit e5e9338 has 1 failures in
🧪 To try this PR locally: bunx bun-pr 44514That installs a local version of the PR into your bun-44514 --bun |
Behaviour change: none
Problem
lexPunctuator()tests<and>inside"[](){}.,;".includes(char)(src/runtime/bake/client/JavaScriptSyntaxHighlighter.ts:475), andlexOperator()takes both characters first.:372-382) is always false. It readsprevCharafter the identifier is consumed, and the call that setsisAfterExtendsOrImplementsalso clears it.highlight(), three helper methods andsensitivePatternshave no user.Fix
htmlTagsSet, their arms and tests, 21 enum members, the.syntax-redrule, the line/column counters. Delete the unused code:highlight(), the three helpers,sensitivePatterns, three options, one local.syntaxHighlightoutput: 0 of 1,878,476 repo lines and 0 of 300,000 seeded fuzz strings differ between main and PR.bake.client.js: 48,402 -> 44,840 bytes (zstd -19: 16,258 -> 15,186).bake.error.js: 23,750 -> 20,188 bytes (zstd -19: 7,824 -> 6,720).tsc -p src/runtime/bake/tsconfig.jsonandtest/bake/dev/{bundle,css,esm,harness,hot,html}.test.tspass on the debug build. Self-reviewed: 4 concerns raised, 3 addressed (Notes).Background
syntaxHighlight()alone (overlay.ts:301,:621). The highlighter does not know the file type.bun install --analyze <files...>#17035, so the JSX paths never ran.<arms reachable (2 lines): plain TypeScript such asExclude<HostAbi, "gnu">gets JSX classes, on 18,205 repo lines. Real JSX colouring: no issue asks for it.Downsides
overlay.ts) and both bundles.Notes
See the dead state on main
divandclassNamecome out assyntax-fg, the plain identifier class. The output is the same on this branch.Why each piece cannot run (line numbers on main)
:475: the<and>arms are inside"[](){}.,;".includes(char).nextToken()also trieslexOperator()beforelexPunctuator(), andOPERATORShas<and>. Nothing else setsisInJSXTag,isJSXTagStartorisInGenericType, so the JSX branch (:337-348) andhtmlTags(:96-207) are never read.:374:prevCharisthis.text[this.pos - 1]afterconsumeIdentifier(). It is always the last identifier character, never:or<. Three of the four disjuncts of the type-reference test need one of those.:361and:512: the fourth disjunct isisAfterExtendsOrImplements. The keyword token that sets it is the same token that the reset at the end ofnextToken()sees.:487-491:isInDestructuringis written on{and}and read only in theprevChar === ":"conjunct.Token.lineandToken.columnare filled increateToken()and never read. The per-character loop inconsume()exists only to feed them.TokenTypeand 10 ofTokenClass. Five lose their last reference here (TokenType.JSXTag,TokenType.JSXAttribute,TokenClass.JSXTag,TokenClass.JSXComponent,TokenClass.JSXAttribute). The other 16 had none..syntax-redhas no producer onceTokenClass.Erroris gone (git grep syntax-red).highlight()(:526) lost its only caller when Remove dead code from the streams bindings, node:http, bun_sys, lsquic_sys, and orphaned files #38213 deletedJavaScriptSyntaxHighlighterComponent.tsx.buildHtmlElement()is called only fromhighlight().languageNameandshowLineNumbersare read only there, andredactSensitiveInformationis read nowhere.consumeTemplateString(),shouldRedactSensitive(),sensitivePatternsand theposlocal inconsumeString():tsc -p src/runtime/bake/tsconfig.json --noUnusedLocals --noUnusedParametersnames this file in 5 diagnostics on main and in 0 on this branch.Measurements
syntaxHighlightfrom main's file and from this branch and compares the strings. Input: every line of the 11,494 git-tracked.ts,.tsx,.js,.jsx,.mjs,.cjs,.mtsand.ctsfiles (216 of them.tsxor.jsx), then 300,000 strings from a seeded generator. The same script reports 18,205 differing lines when main's file is patched to make the<arms reachable, so it does detect a change.bake.client.jsandbake.error.jseach lose 249 lines and change 1 (the CSS string).bake.server.jsis byte-identical. Release binaries embed the zstd forms of the first two.htmlTagsSet is gone. Counted by wrapping theSetandMapconstructors. The release bundler already drops the unusedsensitivePatterns, so the shipped bundles build one Set fewer.consume()loop iterations 37.5 -> 0, dead flag reads 5.16 -> 0, dead flag writes 19.38 -> 0, line and column writes 67.62 -> 0, type-reference test runs 2.22 -> 0. Counted with instrumented copies of both files.${#40125 1 (0 against main), Remove dead code from bun_core, the JSC bindings, the debugger, and 24 other crates #41385 0 (git merge-tree, 7ccf060 against their heads on 2026-10-03).test/bake/dev/{bundle,css,esm,harness,hot,html}.test.ts, 82 tests) pass on the debug build of this branch.Related open PRs
${#40125 fixes template-literal text thatlexTemplateString()drops. It rewritesnextToken()and moves theisAfterExtendsOrImplementsreset block with it. This PR deletes that block. The PR that lands second needs a one-hunk rebase: keepyield token;, drop the reset block. The two compose: with this PR's deletions applied on Fix the bake error overlay highlighter dropping template literal text after${#40125's head, its 26 tests intest/bake/syntax-highlighter.test.tspass, and the output check reports 0 differing lines against Fix the bake error overlay highlighter dropping template literal text after${#40125 alone.Self-review
${#40125 wrongly. Addressed above.${#40125 conflict in one hunk. Not addressed in the diff: both PRs edit the same block, so one of them must rebase. The result of that rebase is tested (see Related open PRs).Left alone on purpose
typeModifiersrepeats whatkeywordColorMapalready says. It runs, so it is not dead.enableColorsis always true for the one caller. The constructor still accepts it.italic,boldandsyntax-fghave no CSS rule inoverlay.css. A rule or a rename changes what the overlay shows.<arm of the terminal highlighter (src/bun_core/fmt.rs:2272) scans a tag name and discards it. A comment there says that is intended.The output check
no test proof · iteration 1 · the description declares no behaviour change, so there is no failing test to prove; the existing suite in CI is the check