Commit Graph
5249 Commits
Author SHA1 Message Date
Chris Tate 794a8cf8a8 Compute products of typed-array reads in 32 bits under bitwise operators (#2289) 2026-10-25 20:58:49 -05:00
Chris Tate 8981b5c0a2 Resolve computed createRequire specifiers at run time (#2079) 2026-10-25 20:29:51 -05:00
Chris Tate c820a6c57f Compute products of typed-array reads in 32 bits under bitwise operators
A sum of products of integer typed-array reads that only reaches a
bitwise operator, such as `(p[j] * 77 + p[j + 1] * 150) >> 8`, now adds
in 32-bit integers like a sum of the reads themselves: a product whose
every result is a safe integer, and never -0, is an exact integer or NaN.
A NaN-coded read passes its validity bit up through those sums, so the
integer result selects 0 for a missed read without a floating compare,
and a loop over such sums vectorizes without converting to doubles.
2026-10-25 20:29:18 -05:00
Chris Tate 26159b264e Ship the lib diagnostics answers with the native distribution (#2285) 2026-10-25 20:23:14 -05:00
Chris Tate 8e4837f94a Run untyped pipeline function stages and later iterable stages (#2276) 2026-10-25 20:17:26 -05:00
Chris Tate fe48f8e69e Type the typed-arguments parameter list as IrParam[] (#2283) 2026-10-25 20:05:13 -05:00
Chris Tate d9bf6c59d2 Ship the lib diagnostics answers with the native distribution
A build with an empty cache type-checked scriptc's own declaration files,
the TypeScript libraries and scriptc's declarations, before reusing the
answer in later builds. That check was 18 ms of a 105 ms first build of
hello world.

- build-native-cli.mts has the built compiler build a module without
  imports and a module with a type error, each in an empty cache, and
  records the content keys of the declaration file sets the checker
  reported no diagnostics in: the checker release, the compiler options,
  and each file's name and sha256. They ship in
  lib/declarations/lib-diagnostics.json, named by the toolchain manifest's
  lib_diagnostics.
- A build whose cache has no answer computes the files' content key and,
  when the shipped answers hold it, uses no diagnostics for those files
  and stores that answer in the cache. The shipped answers apply only
  while the checker is the distribution's own tsc-ts and its package
  version is the release they were recorded with; a changed file has
  another key.
- A compiler the build host cannot run ships without them.
2026-10-25 19:24:27 -05:00
Chris Tate ebf36f94a1 Type the typed-arguments parameter list as IrParam[]
declareTypedArguments appends the hidden positional slots of a
typed-arguments function expression to the parameter list that
declareParams returns. Its parameter was typed
`{ localId: string; name: string; type: IrType }[]`, while the list is an
`IrParam[]` (which also declares `owned?: true`). The native compiler
passes an array whose element type has another layout as a converted copy,
so the slots were appended to the copy and the lifted function kept no
parameters. Building tests/corpus/6380 to 6384 (variadic wrappers that
forward `arguments`) with the native compiler then stopped with SC9001
"closure ...: func type does not match target signature" in 6380, 6381,
6382 and 6384.

The parameter is now typed `IrParam[]`, the type of the list the caller
passes, and the native compiler builds all five programs with output that
matches Node.
2026-10-25 19:12:43 -05:00
Chris Tate 58a64ffb36 Discard the result of void generic methods called through class-backed interfaces (#2275) 2026-10-25 18:56:01 -05:00
Chris Tate 5dfa62b9fc Merge main 2026-10-25 18:54:10 -05:00
Chris Tate 5f9fd5d49e Clone union records whose override is an empty array literal (#2278) 2026-10-25 18:49:23 -05:00
Chris Tate a848a7b349 Resolve the pipeline promise to undefined for an untyped iterable destination
When an untyped destination function returned an async iterable, the
promise form settled its result without a payload, and code that read the
awaited value as an untyped value dereferenced NULL. The promise form for
an untyped destination now resolves to undefined when the destination
returned no promise, or its promise carries no value, as Node does.
2026-10-25 18:44:18 -05:00
Chris Tate 14bb8d4156 Convert asserted values that no ordinary conversion reaches (#2260) 2026-10-25 18:27:26 -05:00
Chris Tate 0063214e42 Keep unchanged partitions cached across edits (#2110) 2026-10-25 18:21:52 -05:00
Chris Tate 417e3a6d08 Call function tables without boxing or reference counting (#2173) 2026-10-25 18:17:54 -05:00
Chris Tate 693b038b15 Keep the result of void generic methods called through class-backed interfaces
A class may implement a void interface method with a method that returns a
value, and JavaScript passes that value on (`console.log(c.publish(m))`).
The call now keeps the dispatch's untyped result, as a call through a
non-generic void member already does, instead of replacing it with
undefined: printing or interpolating it shows the value, and binding it to
a void-typed name checks it.
2026-10-25 18:17:32 -05:00
Chris Tate 81fc7bfa89 Map any parameters of interface method and call signatures as checked values (#2273) 2026-10-25 18:14:23 -05:00
Chris Tate 30cf205e90 Run untyped pipeline function stages and later iterable stages
A pipeline stage that arrives as an untyped value now follows Node's
stage ladder for more shapes. As the first stage, a function is a source
function: the pipeline calls it with { signal } while it is set up and
pumps its result, which must be iterable (ERR_INVALID_RETURN_VALUE
otherwise), and a { readable, writable } pair pumps its readable side.

After the first stage, the pipeline call is lowered once per combination
of its first three untyped stages being functions or not, and a typeof
test picks the branch at run time. A function stage is called with the
previous stage and { signal }; before the last stage its result must be
async iterable, and as the last stage a promise resolves the pipeline's
value and an async iterable feeds the PassThrough pipeline() returns
(SCR_PIPE_DEST_DYN). Any other value that is not a stream becomes
Duplex.from of it, which the next stage reads from without the previous
stage being piped into it, and Duplex.from's ERR_INVALID_ARG_TYPE for
the values it rejects.

An untyped stage followed by an untyped function stage hands its value to
that stage through a cell created per pipeline call, so the function
receives the previous stage's own iterator, as Node's makeAsyncIterable
answers it, instead of an async generator over it.

Untyped web streams, pairs after the first stage, and function stages
that return a stream throw the not-supported error.

RUNTIME_ABI_VERSION goes from 45 to 46 for the new stream exports.
2026-10-25 18:10:32 -05:00
Chris Tate 56099ae21c Erase lambdas that implement a generic method through their context (#2274) 2026-10-25 18:07:47 -05:00
Chris Tate 9067f06c02 Cache the zone offset at UTC midnights for local-time conversions (#2272) 2026-10-25 18:01:58 -05:00
Chris Tate 68151efd37 Name new corpus programs instead of numbering them (#2270) 2026-10-25 17:54:47 -05:00
Chris Tate 5b40498c22 Keep asserted values in a map the lowerer owns
compiler-weak-collections.test.ts refuses weak collections in compiler
sources: the compiled compiler must not depend on which of its values can
serve as weak keys. The lowerer owns the assertedValues cache for its
pass, so an ordinary Map holds it.
2026-10-25 17:52:20 -05:00
Chris Tate 27c00f6577 util: runtime format strings, inspect.custom and colors, untyped promisify (#1911) 2026-10-25 17:46:31 -05:00
Chris Tate b63dc67f9e Let boxable function arms ride a checked-dynamic union (#2269) 2026-10-25 17:44:23 -05:00
Chris Tate cc08abcbe7 Match the pending-flag fallback edge after the callback's receiver block
An indirect callback call now gives the closure an undefined receiver when
it reads one, so the fallback's edge into the pending-flag phi comes from
the receiver block instead of callback.indirect. The flag is still false
on the direct call and true on the fallback.
2026-10-25 17:42:53 -05:00
Chris Tate fad9cbdf57 Keep U+11A7 after a Hangul LV syllable in NFC and NFKC (#2266) 2026-10-25 17:31:45 -05:00
Chris Tate d33b083a3b Cache the zone offset at UTC midnights for local-time conversions
Local setters and the field constructor convert a local time value to
UTC by bracketing it with the zone offset a day before and after, then
checking the candidate instants: three to five localtime(3) calls per
conversion. In glibc each call takes the zone lock and, for dates past
the zone file's last transition, parses the zone's rule string again.

The offsets now come from a per-thread cache of offsets at UTC midnights:
a day whose two midnights agree has that offset throughout, given at
most one transition per day, which the conversion already assumes. A
day with a transition still asks localtime for the instant. A change of
process.env.TZ clears the cache.
2026-10-25 17:30:44 -05:00
Malte UblandClaude Opus 5.5 1733a4c84b Name new corpus programs instead of numbering them
Parallel changes kept taking the same next corpus number (6992 twice, the
Node island programs renumbered several times). The harness never needed
the numbers: it discovers every entry by glob, and 818 programs already
have descriptive names. AGENTS.md now makes a name, without a number, the
convention for new programs and keeps the numbered ones as they are.

The two scripts that sampled programs by number skipped named programs.
They now key a named program by a stable hash of its name, so they sample
it at the same rate; the numbered programs they pick are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 15:17:09 -07:00
Chris Tate 8be991aeca Skip worker cancellation polls in short loops inside another loop (#2261) 2026-10-25 17:14:42 -05:00
Malte UblandClaude Opus 5.5 062700bdde Convert asserted values that no ordinary conversion reaches
`x as T` erases (or, record to record, converts), and the value then meets
its slot with x's representation. Where no conversion reaches the slot
the program was refused:

- a union whose arms only partly convert into T (`api as Partial<Record<
  string, S>>` on `S | Partial<Record<K, S>> | undefined`) failed at the
  next typed slot with SC2003;
- a record or array whose member types the assertion narrows (`models as
  Model<"one">[]` on a union-element array, `item as Narrow` with a
  narrower field) failed with SC2002 or SC2003.

The lowerer now remembers the asserted type of an erased value, and a slot
that would refuse it converts it as asserted: the arms T excludes throw
the catchable TypeError of a lying assertion and the others convert, and
records and arrays take the checked deep conversion, which validates the
value member by member and names the deepest failing path, as a cast of an
unknown value does. The conversions run only where the slot would
otherwise refuse the value, so everything that already lowered keeps its
code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 15:10:31 -07:00
Chris Tate 67c38b5361 Keep the whole union of an optional parameter that reaches a recursive placeholder (#2241) 2026-10-25 17:10:27 -05:00
Chris Tate 48e87d342f Run the linker job directly for host Linux links with lld (#2253) 2026-10-25 17:05:57 -05:00
Chris Tate f1a69d9bb0 Probe hashed number-key maps without normalizing integer keys (#2264) 2026-10-25 17:03:41 -05:00
Malte UblandClaude Opus 5.5 171214b2c2 Discard the result of void generic methods called through class-backed interfaces
A generic method called through an interface value that classes
implement dispatches by name on the checked-dynamic receiver, and the
result converts to the call's instantiated return type. For a void
method, that conversion (`unknown` to `void`) was refused (SC1100). The
result is now discarded, as JavaScript does.

The dispatch helper selected overriding subclasses' erased instances with
a ternary, which has no void form (an internal compiler error once the
call got that far). A void method now selects them with if statements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 15:02:26 -07:00
Malte UblandClaude Opus 5.5 3375304945 Erase lambdas that implement a generic method through their context
A lambda with no type parameters of its own, contextually typed by a
generic signature (`send: (m) => …` for an interface's `send<T>(m:
Message<T>): string`), takes that signature's type parameters: its
parameter is `Message<T>`. A generic lambda written with its own type
parameters already lowers once, erased, with them bound to `unknown`, but
this one tried to map `Message<T>` with `T` unbound and was refused
(SC2009).

It now lowers the same way, erased, binding the contextual signature's
type parameters to `unknown`. Parameters bound in the enclosing scope
keep their bindings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 15:02:24 -07:00
Malte UblandClaude Opus 5.5 be0e825ac1 Map any parameters of interface method and call signatures as checked values
A parameter a TypeScript program types `any` maps to the checked-dynamic
slot for function declarations and spelled function types, but not for
method or call signatures of interfaces and type literals. So
`interface Tool { execute(id: string, params: any): Promise<string> }`
was refused (SC2009), along with every value of the interface, whenever
no class implementing it gave it a class view.

Method and call signatures in program source now take the same rule.

pi's ToolDefinition declares `execute(toolCallId: string, params:
Static<TParams>, …)`. Under --node-islands, typebox's types resolve to
`any`, so the parameter is `any`. The refusal rejected the AgentSession
class through its `_customTools: ToolDefinition[]` field, and
CreateAgentSessionRuntimeResult with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 15:02:20 -07:00
Malte UblandClaude Opus 5.5 605e312e78 Let boxable function arms ride a checked-dynamic union
A union with a checked-dynamic arm (`unknown`, fetch's AbortSignal)
maps to the checked-dynamic value when every other arm is one the
checked-dynamic tree holds faithfully. Function arms were excluded, so
`Progress | AbortSignal | undefined` was refused (SC2009).

The tree boxes a function whose parameters check in and whose result
converts out by reference (canBoxFuncIntoDyn), and `typeof x ===
"function"` narrows it back out to the typed function. Such arms now
join the collapse. The corpus program checks calls, identity (`===`
against the original), and the other arm's members against Node.

pi's SessionManager.listAll takes `onProgressOrSignal?: SessionListProgress
| AbortSignal`. The refusal rejected the whole SessionManager class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 15:02:19 -07:00
Malte UblandClaude Opus 5.5 52abff7c14 Clone union records whose override is an empty array literal
Spreading a union of records and replacing a shared field keeps each
value's variant (lowerUnionRecordClone), but only when every override's
type lifts into the field. An empty array literal is typed `never[]`,
which maps to nothing, so `{ ...entry, content: [] }` over a union fell
back to the ordinary literal path. That path cannot build a union of
spread records, and the literal was refused (SC2001).

An empty array literal now builds an empty array of each arm's own
element type. This covers a field that is an array and a field that is a
union with exactly one array arm (`string | Part[]`).

pi's session-manager repairs messages with missing content this way
(`return [{ ...message, content: [] }]`). The refusal rejected the whole
SessionManager class.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 15:02:07 -07:00
Chris Tate 5f76d41a71 Keep U+11A7 after a Hangul LV syllable in NFC and NFKC
libunicode composes an LV syllable with U+11A7 as if it were a trailing
consonant (U+11A8..U+11C2), which drops it: "가ᆧ".normalize()
gave "가" where Node gives "가ᆧ". U+11A7 is a class-0 vowel
that composes with nothing, so for the composing forms the code points
between occurrences of it normalize on their own and it is kept as it
is. The guard sits in front of the vendored library (scr_unicode_normalize),
for String.prototype.normalize and the NFC step of IDNA mapping.

8009-normalize-hangul-jungseong-o-yae prints the code points of all four
forms for U+11A7 after LV and LVT syllables, conjoining jamo, other
starters and combining marks.
2026-10-25 16:57:11 -05:00
Chris Tate 8d485dcf5f Convert promise and function values into a union's arm of their kind (#2257) 2026-10-25 16:56:50 -05:00
Chris Tate 60c89fd456 Keep record values that subtype reduction folds into an inferred return type (#2069) 2026-10-25 16:50:31 -05:00
Malte UblandClaude Opus 5.5 5a3d6d7903 Call function tables without boxing or reference counting
Values typed `F | undefined` for a function type F are now plain closure
pointers (nullable-pointer unions), so a keyed read of a
`Record<string, F>` or a Map.get no longer allocates a union box. Keyed
record reads, string-keyed Map.get and checked extractions lend the stored
closure as a receiver or callee when ReferenceWrites proves the call cannot
write the locations it was read from, and optional-chain receivers lend
under the same proof. Owned record overflow reads use the inline entry
lookup.

Indirect closure calls skip the ambient receiver bracket for closures
whose bodies never observe it (new ScrClosure.function_kind bit
SCR_FN_RECEIVER_FREE; signature adapters that only forward the receiver
copy it from their original), and a callValue that forwards `dyn.this`
needs no bracket at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 14:49:00 -07:00
Chris Tate bdc90f90cb Merge main 2026-10-25 16:48:31 -05:00
Chris Tate 247f43c0f0 Mark emitted functions sanitize_address only in sanitized builds (#2251) 2026-10-25 16:44:16 -05:00
Chris Tate 8c579a793b Check only the files whose diagnostics the tsc gate keeps (#2263) 2026-10-25 16:39:45 -05:00
Chris Tate 3a900ed9b6 Keep the poll in nested loops whose counter can stop changing at 2^53
The range analysis caps a counter that steps by 1 at 2^53, where
`j + 1 === j`, so a loop such as `for (let j = 2 ** 53 - 2;
j < 2 ** 53 + 10; j++)` has a range of three values at its condition and
was taken for a loop of three runs. It never ends, and without its poll
worker.terminate() could not stop it. A loop's runs now count as bounded
only when a step from every value in its counter's range gives a
different value.
2026-10-25 16:38:27 -05:00
Chris Tate 35161d1883 Cross package values at their declared type where the JS literal type lacks members (#2262) 2026-10-25 16:38:00 -05:00
Chris Tate e3f02c73c9 Probe hashed number-key maps without normalizing integer keys
A number-key Map or Set read whose key has an integer view
(sc_map_entry_f64_int) fell back to the same hashed probe as any double
key, which tests for NaN and -0 before hashing. The fallback is now
sc_map_entry_f64_hashed_int, which takes the integer and converts it to
the key word directly: an integer is never NaN, and zero converts to +0.

Both hashed probes test the absent-key filter only before scanning a map
that keeps no bucket table. The filter keeps two of its 64 bits per key,
so it rejects few absent keys once a map has a bucket table, and the
probe's first bucket read answers those.

The map layout and the runtime lookup are unchanged. Corpus 8331 covers
integers the compiler tracks as integers on hashed maps and absent keys on
small bucket tables, and matches Node's output.
2026-10-25 16:32:27 -05:00
Chris Tate 474edacb4f Prefer the union arm that keeps every field of a converted record (#2259) 2026-10-25 16:26:24 -05:00
Chris Tate a9ea71df7d Compare unions that hold promises as untyped values
A promise converted into a union's promise arm is a new promise, so two
optional slots set to one promise each hold their own conversion, and a
value narrowed out of such a slot may be one too. Union equality compared
those arm payloads by pointer and answered false where Node answers true.

Any comparison between a union with a promise arm and a promise or another
such union now compares both sides as untyped values, where a converted
promise answers with its origin's identity.
2026-10-25 16:22:25 -05:00