Skip to content

Fix $inner object-form detection and reject empty selections - #4114

Open
DmitrySharabin wants to merge 1 commit into
claude/compassionate-brahmagupta-94vewqfrom
claude/inner-spec-detection
Open

DmitrySharabin wants to merge 1 commit into
claude/compassionate-brahmagupta-94vewqfrom
claude/inner-spec-detection

Conversation

@DmitrySharabin

@DmitrySharabin DmitrySharabin commented Sep 17, 2026

Copy link
Copy Markdown
Member

Fix $inner: { language: X } crashing with a TypeError, and empty select values silently disabling inner highlighting instead of failing loud.

  • isInnerSpec keyed on select alone, so { language: X } — the documented shorthand form — was read as an inline grammar. Decide on the key set instead, keeping the select type check so a one-token grammar named select still works inline.
  • select: '', ' , ', [] now throw, hoisted above the !inner early exit, so a malformed grammar fails the same way with or without an inner language.
  • No shipped grammar changes classification: diff, latte, js-templates, and every templating language stay byte-identical.

Not done: a misspelled selector name still fails silently. Rejecting one needs a static walk through nested grammars with nowhere to cache it, and a runtime check can't tell it apart from a selector that legitimately matches nothing (a diff with no deleted lines).

10233 passing / 1 pre-existing pending / 0 failing. lint:ci, tsc, and tsc -p tests/tsconfig.json all clean.

file +
tests/core/registry.js 33 0
src/core/tokenize/embed.js 21 6

🤖 Generated with Claude Code

@DmitrySharabin
DmitrySharabin added this pull request to stack #4113 September 17, 2026 07:58
@netlify

netlify Bot commented Sep 17, 2026

Copy link
Copy Markdown

Deploy Preview for dev-prismjs-com ready!

Name Link
🔨 Latest commit 0dbe335
🔍 Latest deploy log https://app.netlify.com/projects/dev-prismjs-com/deploys/6ab2453030e37d0008a7f1c8
😎 Deploy Preview https://deploy-preview-4114--dev-prismjs-com.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@DmitrySharabin
DmitrySharabin removed this pull request from stack #4113 September 17, 2026 08:01
@DmitrySharabin
DmitrySharabin changed the base branch from claude/split-token-stream-perf to v2 September 17, 2026 08:01
@DmitrySharabin
DmitrySharabin force-pushed the claude/inner-spec-detection branch from c817ab8 to 9d11c85 Compare September 17, 2026 08:01
@DmitrySharabin
DmitrySharabin changed the base branch from v2 to claude/compassionate-brahmagupta-94vewq September 17, 2026 08:02
@DmitrySharabin
DmitrySharabin added this pull request to stack #4115 September 17, 2026 08:02
@DmitrySharabin
DmitrySharabin removed this pull request from stack #4115 September 22, 2026 08:35
@DmitrySharabin
DmitrySharabin changed the base branch from claude/compassionate-brahmagupta-94vewq to v2 September 22, 2026 08:48
@DmitrySharabin
DmitrySharabin force-pushed the claude/inner-spec-detection branch from 9d11c85 to 6fe21cb Compare September 22, 2026 08:48
@DmitrySharabin
DmitrySharabin changed the base branch from v2 to claude/split-token-stream-perf September 22, 2026 08:48
@DmitrySharabin
DmitrySharabin added this pull request to stack #4124 September 22, 2026 08:48
@DmitrySharabin
DmitrySharabin removed this pull request from stack #4124 September 22, 2026 08:49
Base automatically changed from claude/split-token-stream-perf to claude/compassionate-brahmagupta-94vewq September 22, 2026 08:50
`isInnerSpec` keyed on `select` alone, so `$inner: { language: X }` — the
long form that `types.d.ts` documents a bare grammar reference as shorthand
for — was read as an inline grammar and crashed in `matchPattern`. Decide on
the key set instead, keeping the `select` type check so a one-token grammar
named `select` still works inline.

A selector naming no container (`''`, `' , '`, `[]`) silently disabled inner
highlighting. Throw instead, above the `!inner` early exit, so the same
malformed grammar fails the same way with or without an inner language.

Follow-up to #4110, whose code both bugs are in.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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