diff --git a/site/index.html b/site/index.html index 7fd2241b..1412d1ae 100644 --- a/site/index.html +++ b/site/index.html @@ -50,7 +50,10 @@ pre { font: 14px/1.55 var(--mono); font-variant-ligatures: none; background: var(--tile); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 0 0 14px; overflow-x: auto; } pre code { background: none; padding: 0; font-size: inherit; } - pre.err { border-color: #5a2a33; background: #1d1626; color: var(--red); white-space: pre-wrap; } + pre.err { border-color: #5a2a33; background: #1d1626; color: var(--text); white-space: normal; line-height: 1.65; } + pre.err code { display: block; white-space: pre-wrap; overflow-wrap: break-word; } + pre.err code + code { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 138, 128, 0.16); } + .eh { color: var(--red); font-weight: 600; } .eg { color: var(--muted); } .ef { color: var(--blue); font-weight: 600; } .ec { color: #a8d59b; } .ed { color: #6f86a6; white-space: nowrap; } .fname { display: block; font: 12px var(--mono); color: var(--muted); margin: 0 0 6px; } .k { color: var(--blue); } .w { color: var(--amber); } .s { color: #a8d59b; } .c { color: #6f86a6; } .t { color: #c9a7f2; } .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 8px; } @@ -100,7 +103,7 @@
Write to the equation instead, double := 4, and the checker refuses it, in your editor and in CI:
counter.rx:5:3 - error WRITE_TO_NON_SOURCE: double is an equation: only sources are written (W-1)
+counter.rx:5:3 - error WRITE_TO_NON_SOURCE: double is an equation: only sources are written (W-1)
In Solid, destructuring props reads them once and the component stops updating. In .rx, destructure them right in the parameter list: every name follows its prop, defaults and rest included, and the rest spreads onto an element as in JSX.
@@ -131,7 +134,7 @@awaitThere's a loading boundary but no errored one, so the checker says what's missing and how to fix it:
profile.rx:10:7 - error UNHANDLED_FAILURE: a reader of user.name (in <Profile>) can fail with Error and no catch or errored boundary above it discharges Error — show it where it is read: `errored fallback(e) { … } { … }` around the reader (or `await … catch (e) => …` at the await, to make the rejection an answer) (R-f-5)
+profile.rx:10:7 - error UNHANDLED_FAILURE: a reader of user.name (in <Profile>) can fail with Error and no catch or errored boundary above it discharges Error — show it where it is read: `errored fallback(e) { … } { … }` around the reader (or `await … catch (e) => …` at the await, to make the rejection an answer) (R-f-5)
Show the new count at once, send it, and let the server's answer replace the guess. That's guess, which lowers to Solid's createOptimistic. This is how most people write it first:
It has three bugs, and two only show when the network is slow or a request fails. The checker finds all three:
-like.rx:13:3 - error UNHANDLED_FAILURE: a reader of likes (in <Like>) can fail with Error and no catch or errored boundary above it discharges Error — show it where it is read: `errored fallback(e) { … } { … }` around the reader (or `await … catch (e) => …` at the await, to make the rejection an answer) (R-f-5)
-like.rx:7:3 - error UNCAUGHT_ACTION_FAILURE: action send can fail with Error and does not catch it: a handler cannot (it does not await the action) — `try { … } catch (e) { … }` in the body (R-f-6)
-like.rx:13:3 - error GUESS_WHILE_LOADING: <button> onClick starts `send`, which can run `guess likes` while likes is loading a new question (its question reads what the click reads): the guess composes on the previous answer, and the new answer replaces it, so the change disappears while it is out (D-34) — put the element inside the `loading` region whose content reads likes, or give it `disabled={pending? likes}`, or keep the pending change in a source of its own until it lands (AC-3a)
+like.rx:13:3 - error UNHANDLED_FAILURE: a reader of likes (in <Like>) can fail with Error and no catch or errored boundary above it discharges Error — show it where it is read: `errored fallback(e) { … } { … }` around the reader (or `await … catch (e) => …` at the await, to make the rejection an answer) (R-f-5)+like.rx:7:3 - error UNCAUGHT_ACTION_FAILURE: action send can fail with Error and does not catch it: a handler cannot (it does not await the action) — `try { … } catch (e) { … }` in the body (R-f-6)+like.rx:13:3 - error GUESS_WHILE_LOADING: <button> onClick starts `send`, which can run `guess likes` while likes is loading a new question (its question reads what the click reads): the guess composes on the previous answer, and the new answer replaces it, so the change disappears while it is out (D-34) — put the element inside the `loading` region whose content reads likes, or give it `disabled={pending? likes}`, or keep the pending change in a source of its own until it lands (AC-3a)
The last one is the subtle one. Click while the count is still reloading and your +1 lands on the old answer, then vanishes when the new one arrives. Each error names the fix, and the fixed version passes:
like.rxexport default component Like(props: { id: number }) {
likes = await fetchLikes(props.id) catch (e) => 0
@@ -180,7 +183,7 @@ The "Saving…" that never shows
let r = await saveName("Ann") catch (e) => e.message
status := r
}}>{status}</button>
-save.rx:5:3 - error HELD_WRITE: status := … comes before an `await` in a body that is an action because it writes and awaits (AC-1b), so it is held until the body ends (AC-1): for state that shows while the work runs, `guess status := …` (a source with a question, ST-5c); for a reset that lands now, `onFlush(() => { status := … })` (EF-8); to hold it on purpose, declare the action (`action name() { … }`); or write it after the `await` (AC-1c)
+save.rx:5:3 - error HELD_WRITE: status := … comes before an `await` in a body that is an action because it writes and awaits (AC-1b), so it is held until the body ends (AC-1): for state that shows while the work runs, `guess status := …` (a source with a question, ST-5c); for a reset that lands now, `onFlush(() => { status := … })` (EF-8); to hold it on purpose, declare the action (`action name() { … }`); or write it after the `await` (AC-1c)
Read, await, write back. If anything changed tags in between, this overwrites it.
action add(t: string) {
@@ -188,7 +191,7 @@ The write that undoes another click
let saved = await addTag(t) catch (e) => t
tags := before + " " + saved
}
-tags.rx:5:3 - error STALE_WRITE_BACK: tags := … after an `await` is computed from tags as it was read before that `await`: whatever changed tags in between (another action, a reload) is overwritten — write functionally (`tags := v => …`, W-6), which applies to tags as it stands at the write, or guess it (`guess`, AC-3) and let the answer replace the guess (AC-1e)
+tags.rx:5:3 - error STALE_WRITE_BACK: tags := … after an `await` is computed from tags as it was read before that `await`: whatever changed tags in between (another action, a reload) is overwritten — write functionally (`tags := v => …`, W-6), which applies to tags as it stands at the write, or guess it (`guess`, AC-3) and let the answer replace the guess (AC-1e)