Skip to content

Commit ce0f01e

Browse files
committed
R-1a: an equation's value is never a promise (MISSING_AWAIT)
An equation lowers to a memo, and Solid's memo consumes a promise or async iterable its function returns, so R-1's "a Promise-valued expression without await is an ordinary value" contradicted the lowering. The type projection now wraps each equation as __.eq(e), which refuses a promise or a stream on any branch as MISSING_AWAIT (13 TY-5b). `any` stays silent; noted in R-1a. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWMgQnVJdZuGmj1hSdC
1 parent aa85cbd commit ce0f01e

8 files changed

Lines changed: 63 additions & 8 deletions

File tree

‎compiler/src/prelude.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import type { JSX } from "@solidjs/web/jsx-runtime";
33
export declare function await_<T>(v: T): Awaited<T>;
44
export declare function awaitS<T>(v: T): T extends AsyncIterable<infer U> ? U : Awaited<T>;
5+
/** R-1: Solid's memo consumes a promise or a stream its function returns, so an equation's value is never one — `await` says
6+
* where it enters (`any`: not known here; Solid still consumes it). */
7+
type Async<T> = 0 extends (1 & T) ? false : true extends (T extends PromiseLike<any> | AsyncIterable<any> ? true : false) ? true : false;
8+
export declare function eq<T>(v: T, ok: Async<T> extends true ? "MISSING_AWAIT: an equation's value is a promise or a stream, which Solid consumes; write await e (or await* e for a stream)" : true): T;
59
export declare function first<T, I>(v: T, init: I): T | I;
610
export declare function pre<T>(init?: T): T;
711
export declare function pending(v: unknown): boolean;

‎compiler/src/project.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl Proj<'_> {
496496
Decl::Eq { name, e, line, ty, .. } => {
497497
let nm = self.name(name, sp, &mut at);
498498
let a = self.ann(ty, sp, &mut at);
499-
let v = self.expr(e, false, Some(name));
499+
let v = Code::of("__.eq(").c(self.expr(e, false, Some(name))).t(", true)"); // R-1: no promise without `await`
500500
self.w.emit(Code::of(ind).t(ex(d)).t("const ").c(nm).c(a).t(" = ").c(v).t(";").from(sp), *line);
501501
}
502502
Decl::Provide { name, e, line, .. } => {

‎ref/types/project.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// `projectTsrxForTypecheck` does for `.tsrx` — and TypeScript's diagnostics are reported on `.rx` lines. Types stay
33
// TypeScript's (07 §2); the projection only says what each form is, as a value, to TypeScript:
44
// a source or an equation is a `const` of its value's type (reads are values, 02 V-1); a write is `__.set(target, v)`,
5-
// which checks `v` against the target; an equation's `await` is `__.await(e)`, its answer's type; a view is JSX over
5+
// which checks `v` against the target; an equation's `await` is `__.await(e)`, its answer's type, and an equation is `__.eq(e)`, never a promise (R-1); a view is JSX over
66
// Solid's JSX types, so a component's props and what a reader may insert are checked where they are written.
77
// The projection is for checking only: it is never run, and its order is the dependency order (E-7).
88
import type { Decl, Expr, Markup, Program, Stmt, Target } from "../src/ast.ts";
@@ -25,6 +25,10 @@ export const PRELUDE = `// ReactiveScript's forms, as TypeScript sees them (type
2525
import type { JSX } from "@solidjs/web/jsx-runtime";
2626
export declare function await_<T>(v: T): Awaited<T>;
2727
export declare function awaitS<T>(v: T): T extends AsyncIterable<infer U> ? U : Awaited<T>;
28+
/** R-1: Solid's memo consumes a promise or a stream its function returns, so an equation's value is never one — \`await\` says
29+
* where it enters (\`any\`: not known here; Solid still consumes it). */
30+
type Async<T> = 0 extends (1 & T) ? false : true extends (T extends PromiseLike<any> | AsyncIterable<any> ? true : false) ? true : false;
31+
export declare function eq<T>(v: T, ok: Async<T> extends true ? "MISSING_AWAIT: an equation's value is a promise or a stream, which Solid consumes; write await e (or await* e for a stream)" : true): T;
2832
export declare function first<T, I>(v: T, init: I): T | I;
2933
export declare function pre<T>(init?: T): T;
3034
export declare function pending(v: unknown): boolean;
@@ -161,7 +165,7 @@ class Proj {
161165
}
162166
for (const d of this.order(ds)) {
163167
if (d.k === "source") this.w.emit(`${ind}${ex(d)}const ${d.name}${ann(d.type)} = ${typeText(d.type) ? `__.typed<${typeText(d.type)}>(${this.expr(d.init, false)})` : `__.src(${this.expr(d.init, false)})`};`, d.line);
164-
if (d.k === "eq") this.w.emit(`${ind}${ex(d)}const ${d.name}${ann(d.type)} = ${this.expr(d.e, false, d.name)};`, d.line);
168+
if (d.k === "eq") this.w.emit(`${ind}${ex(d)}const ${d.name}${ann(d.type)} = __.eq(${this.expr(d.e, false, d.name)}, true);`, d.line); // R-1: no promise without `await`
165169
if (d.k === "provide") this.w.emit(`${ind}__.provide(${d.name}, ${this.expr(d.e, false)});`, d.line);
166170
}
167171
for (const d of ds) if (d.k === "effect") {

‎ref/types/run.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ for (const u of units) {
6464
const got: string[] = [];
6565
for (const [f, p] of u.files) for (const d of byFile.get(f) ?? []) {
6666
const line = d.file && d.start !== undefined ? d.file.getLineAndCharacterOfPosition(d.start).line : 0;
67-
const msg0 = ts.flattenDiagnosticMessageText(d.messageText, " "); const own = /"(WIRE_VALUE): ([^"]*)"/.exec(msg0); // a rule the projection states as a type
67+
const msg0 = ts.flattenDiagnosticMessageText(d.messageText, " "); const own = /"(WIRE_VALUE|MISSING_AWAIT): ([^"]*)"/.exec(msg0); // a rule the projection states as a type
6868
if (own) { got.push(`${own[1]} ${p.rx.split("/").pop()}:${p.lines[line] ?? "?"}: ${own[2]}`); continue; }
6969
got.push(`TS${d.code} ${p.rx.split("/").pop()}:${p.lines[line] ?? "?"}: ${ts.flattenDiagnosticMessageText(d.messageText, " ").slice(0, Number(process.env.MSG ?? 220))}`);
7070
if (process.env.DEBUG) console.log(`--- ${f}\n${p.code.split("\n").map((l, i) => `${String(i + 1).padStart(3)}${i === line ? ">" : " "} ${l}`).join("\n")}`);

‎scenarios/S-types-1.md‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# S-types-1 — Types: the program as TypeScript sees it
22

3-
Rules exercised: TY-1–TY-4 (08 §TY), 07 §2.
3+
Rules exercised: TY-1–TY-5 (08 §TY), 07 §2, 04 R-1a.
44

55
## Modules
66

@@ -170,3 +170,32 @@ export default component App() {
170170

171171
SF-6a, statically: a `Date` is an instance of a class, so the result is
172172
not data. (Untyped, the check is the run time's, S-sf-1.)
173+
174+
```
175+
-- types: MISSING_AWAIT
176+
import { fetchUser } from "./api"
177+
export default component App() {
178+
source id := 1
179+
user = fetchUser(id)
180+
181+
<p>{id}</p>
182+
}
183+
```
184+
185+
R-1: the equation lowers to a memo, and Solid's memo consumes the promise
186+
its function returns, so `user` would be pending at run time while the
187+
source says it is a value. The value is never a promise: write
188+
`await fetchUser(id)`.
189+
190+
```
191+
-- types: MISSING_AWAIT
192+
import { fetchUser } from "./api"
193+
export default component App() {
194+
source id := 1
195+
user = id > 0 ? fetchUser(id) : null
196+
197+
<p>{id}</p>
198+
}
199+
```
200+
201+
A promise on one branch is enough: on that branch Solid consumes it.

‎spec/04-rows.md‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,21 @@ and where they may not go.
4343
- **R-1 (Entry).** `pending` enters only through `await e` in reactive scope.
4444
`await` is the row marker, not a scheduler: if `e` is already a value,
4545
`await e` is `e` in the same instant with no tick; if `e` is a promise or an
46-
async iterable, the equation is pending until the first answer lands. A
47-
Promise-valued expression without `await` is an ordinary value of type
48-
Promise and is never pending.
46+
async iterable, the equation is pending until the first answer lands.
47+
- **R-1a (No promise without `await`).** [ruled 2026-10-28] An equation's
48+
value is never a promise or an async iterable. It lowers to a memo, and
49+
Solid's memo consumes one its function returns, so `x = fetchUser(id)`
50+
would be pending at run time while the source says it is a value. Where
51+
the type is known, an equation whose value may be a promise or a stream
52+
(on any branch) is `MISSING_AWAIT`, checked by the type layer (13 TY-5b):
53+
write `await e` or `await* e`. A promise inside a value
54+
(`{ p: fetchUser(id) }`, `[a, b]`) is not consumed and is passed as one.
55+
Where the type is `any`, the check cannot see it and Solid still consumes
56+
the promise; the rows (R-3) and the AC checks then miss that entry. Where
57+
more could be done: refuse an `any`-typed call into a JS import in an
58+
equation without `await`; noted, not adopted. (Replaces "a Promise-valued
59+
expression without `await` is an ordinary value of type Promise and is
60+
never pending", which the lowering contradicted.)
4961
- **R-2 (Flow).** An equation that reads a pending value is pending. A reader
5062
of a pending value is a pending reader (05 decides what that does to the
5163
screen). An effect whose compute half is pending does not run its apply
@@ -244,6 +256,7 @@ tracked. Inspired by solid-yield's typed failure color; the checks are
244256
| `PENDING_ASYNC_UNTRACKED_READ` | U | R-8 |
245257
| `PENDING_ASYNC_FORBIDDEN_SCOPE` | U | R-8 |
246258
| `SYNC_NODE_RECEIVED_ASYNC` | U | R-1 |
259+
| `MISSING_AWAIT` (new) | S | R-1a: an equation whose value may be a promise or a stream (13 TY-5b) |
247260
| `ASYNC_WATERFALL` | S | an `await` whose inputs depend on another `await` (R-2) |
248261
| `UNTRACKED_ASYNC_HANDLER` (structural half) | S | a handler that awaits with no write before and no `action` |
249262
| `UNHANDLED_FAILURE` (new) | S | R-f-5 |

‎spec/13-types.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ does for `.tsrx`. Nothing here is a second type system.
7575
checked to be data: a function, or an instance of a class (a `Date`),
7676
where the types are known is `WIRE_VALUE` at compile time. Where they are
7777
`any` — an untyped parameter — the run-time check stands.
78+
- **TY-5b (R-1a statically).** An equation is projected as `__.eq(e)`,
79+
whose type is `e`'s and which refuses a promise or an async iterable on
80+
any branch: `MISSING_AWAIT`. Where the type is `any` the check is silent
81+
(04 R-1a). (Ruled 2026-10-28; S-types-1.)
7882

7983
## Found by the type layer (2026-10-25)
8084

‎spec/99-diagnostics.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ named.
133133
| `CONTENT_MODEL` | S | 10 SV-7d: nesting the HTML parser restructures, across templates (component roots, branches, placed children) | S-server-4 |
134134
| `IMPORT_ROW_MISMATCH` (SF-5) | S | `server`/`client` on an import that a `.d.rx` declares otherwise | S-sf-1 |
135135
| `WIRE_VALUE` | S/R | 12 SF-6a: at compile time where the types are known (13 TY-5a), else at run time | S-sf-1, S-types-1 |
136+
| `MISSING_AWAIT` (new) | S | 04 R-1a: an equation whose value may be a promise or a stream, which Solid's memo would consume; write `await e` (13 TY-5b) | S-types-1 |
136137
| `TSnnnn` | S | 13 TY-1: TypeScript's errors over the projection, on `.rx` lines | S-types-1 |
137138

138139
## The advisory rows (ruled 2026-10-23, in part)

0 commit comments

Comments
 (0)