Skip to content

Diagnostics: parse errors name the JS habit, and every code has a fix page - #42

Merged
ryansolid merged 2 commits into
mainfrom
claude/project-thread-rtxj3o
Nov 10, 2026
Merged

ryansolid merged 2 commits into
mainfrom
claude/project-thread-rtxj3o

Conversation

@ryansolid

Copy link
Copy Markdown
Member

Requested by Ryan · project thread

Errors guide you the way Solid's dev diagnostics do: each code's message carries the repair, and a page for that code explains why and shows a fix.

Parse errors

Parse errors used to give no code and no column, so JavaScript habits got messages like "declaration or markup near …". Now, when the failing line reads like JS, React or Solid, the message names the habit and the .rx it most likely meant:

Code Example
JS_LOCAL const n = 1 / let d = n * 2 in a component or at top level
JS_FUNCTION function f() { … }
JS_RETURN return <p>…</p> in a component
JS_API [n, setN] = createSignal(0), useState, …
ASSIGNMENT (W-1) n = n + 1, n += 1, n++ in a handler
REACTIVE_WRITE_IN_OWNED_SCOPE (W-2) onClick={() => n := 1}: the arrow needs a braced body
const.rx:2:14: error JS_LOCAL [07] expected a declaration or markup at the end of the line — `const` declares a local only in a handler or action body: in a component or at a module's top level, state is `source x := …` and a value computed from others is an equation, `x = …`
  • ref/src/parse.ts and compiler/src/parse.rs share one hint function. Any other parse error is PARSE. The hint goes after the parser's own message, so the rule a scenario matches is unchanged.
  • rxc check prints parse errors as file:line:col: error CODE [rule] message. JSON, Vite and the editor get the code, plus a message without the path: line n: prefix.
  • @reactivescript/compiler's Vite path now reports a parse error as a diagnostic with a code, where it used to report a bare error string.
  • New scenario S-parse-hints, which scenario rejections can now match by parse code.

guide/diagnostics.md

  • One section per code (63): what happened, why, and a fix, citing the rule ids. Codes keep Solid's names where Solid has the same check.
  • 46 rx before / rx after program pairs. compiler/tests/diagnostics_page.rs checks that every code the crate emits has a section, that each before gets its section's code, and that each after checks clean.
  • Shipped in @reactivescript/compiler (prepack copies guide/*.md into the package).
  • Linked from three places:
    • Vite errors end with one line per code that points at the installed page (…/guide/diagnostics.md#held_write).
    • rx-tsc prints the same links.
    • The language server sets LSP codeDescription, so the code is clickable in the editor.
  • spec/99-diagnostics.md lists the new parse codes, and guide/language.md points to the page.

Checks

  • cargo test --release: pass, including the new page test.
  • ref: npm test 122/122 scenarios pass. npm run crate 342/342 programs agree between the crate and ref/.
  • compiler: npm test passes. npm pack --dry-run includes guide/.
  • rx-language-server: test/run.js 16/16 pass. test/tsc.js 3/4: "the shop passes" fails with TS2741 on examples/shop, and it fails the same way on main (checked with these changes stashed), so this PR doesn't cause it.
  • CI's compiler workflow doesn't run cargo test, so the page test runs locally only for now.

Not in this PR: separate why / fixes[] JSON fields with editor quick fixes, exact locations for checker errors (HELD_WRITE points at the handler's line), and fixes in the few checker messages that have none (INVALID_REFRESH_TARGET, INVALID_AFFECTS_TARGET, PRE_OF_NON_REACTIVE, UNKNOWN_COMPONENT, ACTION_CALLED_IN_OWNED_SCOPE). For now this page explains them.


Generated by Claude Code

Parse errors now carry a code and a column. When the failing line reads like
JavaScript, React or Solid, the message appends the .rx it most likely meant:
JS_LOCAL (const/let in a component), JS_FUNCTION, JS_RETURN, JS_API
(createSignal, useState, ...), ASSIGNMENT (`=`, `+=`, `++` on a source, W-1)
and REACTIVE_WRITE_IN_OWNED_SCOPE (`() => x := ...`, W-2). Same `hint` in
ref/src/parse.ts and compiler/src/parse.rs; scenario S-parse-hints.

guide/diagnostics.md has one section per code (63): why, and the fix, with
before/after programs. compiler/tests/diagnostics_page.rs checks that every
code the crate emits has a section, every `rx before` gets its code and
every `rx after` checks clean. The page ships in @reactivescript/compiler
(prepack copies guide/), Vite errors end with each code's link, rx-tsc
prints them, and the language server sets codeDescription.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117BoWPJ3SHHnqKDEZWuteB
@ryansolid ryansolid self-assigned this Nov 10, 2026

Copy link
Copy Markdown
Member Author

The red build jobs come from main, not from this PR. They stop at npm ci in compiler/ because package.json and package-lock.json are out of sync: the lock is missing @reactivescript/compiler-<platform>@0.1.0. main fails the same way, and so does 5bcdbe6, the last green run. Those platform packages have been on the registry since the 0.1.0 release, so npm now resolves the optional dependencies the lock never recorded.

Running npm install --package-lock-only in compiler/ adds the platform entries to the lock (+88/-8), and npm ci passes after that. That's a lockfile and release-flow change (the next version bump will go through the same thing), so I'm holding it for Ryan's call instead of widening this PR.


Generated by Claude Code

@ryansolid
ryansolid merged commit 8d20916 into main Nov 10, 2026
17 checks passed
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