Commit Graph
562 Commits
Author SHA1 Message Date
.CooCoo 26aa108881 Merge pull request #10624 from dotCooCoo/fix/js-export-async-function
JavaScript: modules export async function declarations
2026-12-03 07:30:40 -08:00
.CooCoo 0727763819 Merge pull request #10620 from dotCooCoo/fix/async-function-subclass
Scripts: a class can extend AsyncFunction and GeneratorFunction
2026-12-03 07:30:16 -08:00
.CooCoo 9a1f0e92ea Merge pull request #10619 from dotCooCoo/fix/eval-default-param-annexb
JavaScript: eval in a default parameter leaves a parameter of a block function's name alone
2026-12-03 07:29:53 -08:00
dotCooCoo 98c6e5fb20 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 15:57:11 -08:00
.CooCoo 822651dc7a Merge pull request #9266 from dotCooCoo/feat/scripts-export-autocad
Scripts: exportFile writes DXF with ExportOptionsAutoCAD
2026-12-02 15:42:04 -08:00
dotCooCoo e369013463 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 15:37:51 -08:00
dotCooCoo 66c71eeb8d JavaScript: modules export async function declarations
`export async function f() {}` stopped with "expected a declaration after
'export'", because the module parser checked only for `var`, `function`
and lexical declarations. `export default async function` read the
function as an expression bound to the default binding, so a named one
did not bind its name in the module and was not hoisted.

Both forms now parse as async function declarations, as ECMA-262 2017
section 15.2.3 (ExportDeclaration with HoistableDeclaration) gives.
Async generators stay syntax errors here, as in a plain declaration.

The export forms were missed when #9131 added async functions.
2026-12-02 14:24:43 -08:00
dotCooCoo 26c62f92f4 Scripts: a class can extend AsyncFunction and GeneratorFunction
`new` on a class that extends `AsyncFunction` or `GeneratorFunction`
threw "this built-in cannot be subclassed", because the subclass check
listed only `Function` among the function constructors. Both now take
the subclass's prototype from `new.target`, as CreateDynamicFunction
asks (ECMA-262 2017 section 19.2.1.1.1). `AsyncFunction` also parses
its source before it reads `new.target.prototype`, as `Function` and
`GeneratorFunction` already did.

The check came in with the classes support (#9094) and `AsyncFunction`
with async functions (#9131).
2026-12-02 14:20:58 -08:00
dotCooCoo 326c88a8f3 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 14:12:01 -08:00
dotCooCoo 6a3c6cc7a6 JavaScript: eval in a default parameter leaves a parameter of a block function's name alone
A block function in eval code run from a default parameter's value no
longer replaces a parameter of the same name with its variable. The
parameters are bindings between the eval code and the function's
variable environment, so the function gets no variable (Annex B.3.2.3)
and stays in its block. A name that no parameter has still gets the
variable.

The fault came with b900ea2308, which checks the environments out to
the variable environment but not the parameters' environment that a
default parameter's eval declares into.
2026-12-02 14:10:05 -08:00
dotCooCoo 1f2e9bff33 Merge main into feat/scripts-export-autocad 2026-12-02 14:02:36 -08:00
dotCooCoo d583b8053f Merge main into feat/scripts-pageitem-transforms 2026-12-02 13:09:44 -08:00
.CooCoo aeddf2f03a Merge pull request #9077 from dotCooCoo/feat/scripts-api-d8b-tracing
Scripts: PlacedItem.trace and RasterItem.trace make an Image Trace object with its tracing options
2026-12-02 12:37:15 -08:00
dotCooCoo 930c02ce8f Merge main into feat/scripts-pageitem-transforms 2026-12-02 12:20:10 -08:00
dotCooCoo d656458366 Merge main into feat/scripts-export-autocad 2026-12-02 11:52:58 -08:00
dotCooCoo fe3d001806 Merge main into feat/scripts-export-autocad 2026-12-02 11:48:42 -08:00
dotCooCoo cd3a0da644 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-02 11:39:00 -08:00
.CooCoo d0d73ff553 Merge pull request #9131 from dotCooCoo/feat/js-es2017-async-await
JavaScript: .js scripts run async functions and await
2026-12-02 11:37:17 -08:00
dotCooCoo 497e2eb4e7 Merge main into feat/scripts-api-d8b-tracing 2026-12-02 11:33:20 -08:00
.CooCoo e25243aeb4 Merge pull request #9135 from dotCooCoo/feat/js-es2015-proxy-reflect
JavaScript: ES2015 realms have Proxy and Reflect
2026-12-02 11:15:55 -08:00
dotCooCoo 8aa51b123e JS: assert the qualified name's value in the E4X async test
CI's test-lint step failed on with_e4x_async_before_a_double_colon_is_a_qualified_name:
both of its assertions only checked is_ok. The test now runs x.async::b with async
bound to a Namespace and asserts that it selects the namespaced child.
2026-12-02 10:16:37 -08:00
dotCooCoo c0b4413a5a JS: fix async function review points
- AsyncFunction.prototype has Symbol.toStringTag "AsyncFunction",
  configurable only.
- await checks the room for the awaited promise's reaction or job and
  the suspended frame's bytes before it attaches the reaction, so a
  suspension stays within the heap limit.
- An async function's return pops its frame before resolving its
  promise, so a then getter on the returned value runs without it.
  Returning the function's own promise rejects it at the return.
- Block functions whose variable was not declared are kept in a hash
  set, so each block function's lookup takes constant time.
- A shorthand await in an object pattern of an async arrow function's
  head is a syntax error, and the head accepts patterns with defaults
  such as async ({a = 1}) => a. async({a = 1}) without an arrow is
  still a syntax error.
- docs: .jsx files and source strings run with module: true have
  Promise and the async syntax; await is an identifier only in script
  code.
2026-12-02 08:30:09 -08:00
dotCooCoo ff165a7ec2 JavaScript: descriptor bags keep ECMAScript key order; Symbol hooks need ES2015
Object.defineProperties, Object.create, seal and freeze read an ordinary
object's own names in ECMAScript order (array indices ascending first) in
an ES2015 run, through proxies without an ownKeys trap too; without the
option they keep the order for-in visits.

concat reads Symbol.isConcatSpreadable and with scopes read
Symbol.unscopables only in an ES2015 run, so a Symbol set by an earlier
run does not change code run without the option.

Tests: the host-function proxy refusal checks the throw and that neither
the host function nor the trap ran; the bound-constructor test sets the
custom prototype before constructing.
2026-12-02 08:10:45 -08:00
dotCooCoo 757b667f3d Scripts: for-in keeps the names a proxy listed before the chain returns to it
A getPrototypeOf trap may return the same proxy again. Its second visit
replaced the positions the first visit recorded, so a name only the first
ownKeys call returned was never visited. Each visit now adds its new
positions to the proxy's record, each pair counted once against the heap
limit, and the records are sorted and compacted once after the walk.
2026-12-02 07:39:46 -08:00
dotCooCoo 444c46c515 Scripts: for-in visits a name when a getPrototypeOf trap returns a new proxy each time
A for-in loop asks only the proxies whose ownKeys trap listed a name for
its descriptor. When a getPrototypeOf trap returned a new proxy of the
same target on each call, the proxy met before each name was not the one
that listed it, so the name was skipped. The loop now records, for each
proxy, the proxy its prototype lookup returned, and a new proxy of that
same target in its place answers for it. Proxies that list nothing are
recorded too, so another proxy of their target does not answer for them,
and the listing proxies stay rooted until the iterator holds them.

Follows #10185.
2026-12-02 07:12:47 -08:00
dotCooCoo 337b47a309 JavaScript: with scopes honor Symbol.unscopables; concat reads isConcatSpreadable
- A `with` scope reads `Symbol.unscopables` after it finds a name, through
  a proxy's `get` trap, and skips the binding when that object's property
  for the name is truthy.
- `concat` reads `Symbol.isConcatSpreadable`, through proxy traps; a
  defined value decides whether the object is spread.
- `Object.keys` and `Object.getOwnPropertyNames` keep the target's order
  through empty-handler proxies.
- `%TypedArray%.from` and `of` construct through a proxy constructor and
  check that the result is a typed array long enough.
2026-12-02 06:23:12 -08:00
dotCooCoo 080f3c4a84 JavaScript: legacy reflect find skips proxy traps; replacer lists charge kept names
- `reflect.find` reads the reflection object and its lists with ordinary
  [[GetOwnProperty]], so a proxy receiver throws a TypeError without its
  getOwnPropertyDescriptor trap running.
- `JSON.stringify` charges each distinct name a replacer array keeps for
  the length of the call, instead of reserving bytes for the whole length,
  so a long sparse replacer list no longer hits the heap limit.
- A test checks that an outer proxy reads an inner proxy target's
  descriptors in its trap's combined order of names and Symbols.
2026-12-02 06:01:07 -08:00
dotCooCoo f2d79f2460 Merge main into feat/js-es2015-proxy-reflect 2026-12-02 05:57:22 -08:00
dotCooCoo c2a2f38a4e Merge main into feat/js-es2017-async-await 2026-12-02 05:32:01 -08:00
dotCooCoo e61533b320 Merge main into feat/scripts-pageitem-transforms 2026-12-02 05:28:03 -08:00
.CooCoo 2498ef4682 Merge pull request #10185 from dotCooCoo/feat/js-object-set-prototype-of
Scripts: ES2015 realms have Object.setPrototypeOf
2026-12-02 02:36:46 -08:00
dotCooCoo d09d00fa25 Merge main into feat/scripts-export-autocad 2026-12-02 02:20:49 -08:00
dotCooCoo 622459dd4b JavaScript: roll back every object of a family after a failed class install
main's failed-install roll back (#10544) read one object for each family
and handle, while this branch keeps one for each branch of the family.
The install now records the class and prototype of each of those objects
and the roll back puts each one back, so the merged tree builds again.
2026-12-02 01:42:49 -08:00
dotCooCoo 4bcdc5d77c Merge main into feat/scripts-api-d8b-tracing 2026-12-02 01:26:36 -08:00
dotCooCoo 91f76bc40a JavaScript: Symbol reads through a proxy call its get trap, and ownKeys traps may return Symbol keys
A read of a Symbol key on a proxy, or on an object with a proxy on its
prototype chain, now calls the proxy's get trap with the Symbol and the
receiver (ECMA-262 9.5.8) and checks the result against the target's
non-configurable Symbol properties.

An ownKeys trap may now return Symbol keys (9.5.11). A Symbol given
twice, a non-configurable Symbol key of the target left out, and for a
non-extensible target any Symbol key left out or added throw a
TypeError. The target's descriptors are read in its key order with one
isExtensible call. Reflect.ownKeys, Object.getOwnPropertySymbols and the
Object functions that list keys take a proxy's keys from one trap call
and keep the order the trap gave, Symbols included.
2026-12-02 01:09:46 -08:00
dotCooCoo 7e3feff631 Tests: drop a String-to-String conversion in the sealed-global proxy test
Clippy's useless_conversion lint stopped the gate at
crates/js/src/proxy_tests.rs:127, where `names.clone().into()` converted
a String to itself. The assertion compares the same value.
2026-12-02 00:32:34 -08:00
dotCooCoo 0a66352e8c JavaScript: a failed host class install adds none of its classes
Realm::define_host_classes registered each class, and defined its global
constructor, before it checked the next one. A batch whose second class
named an unknown parent or a member twice failed with the first class
already installed, so a retry failed with "defined twice". A failed
instance did the same, and could leave an object scripts held with a
class the realm no longer had.

Every class's name, parent and members are now checked before any class
is added, so a child must still follow its parent in the batch. A
failure after that point removes the classes added, puts back each
global the call replaced and the class of each object an instance moved
to a new class. The replaced globals stay rooted until the call ends, so
a collection during the call does not free them.
2026-12-01 23:19:55 -08:00
dotCooCoo 8c78d72c9f Scripts: for-in asks only the proxies that listed a name
- A for-in loop now records, for each proxy whose ownKeys trap it called,
  the positions of the names that proxy returned, and asks a proxy for a
  name's descriptor only when that proxy listed the name. A proxy that did
  not list a name no longer hides an inherited one, and the proxy that did
  is still asked after a prototype change moves it on the chain. The
  records keep their proxies reachable and count against the heap limit.
- The check before each name walks own properties object by object, so a
  typed array without the element a name gives no longer hides that name
  on its prototypes.
- Function.prototype.apply reads the list's length with ToLength in a run
  with the ES2015 option, so a negative length gives no arguments; other
  runs keep ToUint32.
- Docs: typeof on a revoked proxy does not throw, and a setPrototypeOf
  trap that returns true may leave the prototype unchanged.
2026-12-01 21:07:58 -08:00
dotCooCoo f411ad0879 Merge main into feat/js-es2015-proxy-reflect 2026-12-01 20:31:33 -08:00
dotCooCoo 938de6e8a3 JavaScript: Symbol keys reach a proxy's target, Reflect keeps Symbol keys, and a sealed global skips Proxy and Reflect
- A Symbol key on a proxy now goes to its innermost target for every
  operation: a definition, write or deletion no longer lands on the proxy
  object itself. Object.freeze, Object.seal, Object.isFrozen and
  Object.isSealed therefore work on a proxy whose target has Symbol
  properties instead of throwing a TypeError.
- Reflect.get, set, has, defineProperty, deleteProperty and
  getOwnPropertyDescriptor keep a Symbol key as a Symbol, and
  Reflect.ownKeys lists Symbol keys after the string keys.
- A realm whose global object an earlier run made non-extensible runs its
  ECMAScript 2015 code without Proxy and Reflect, instead of failing every
  run with an installation error.
- JSON.stringify charges a replacer array's names to the heap as they are
  kept, not the array's whole length up front.
- for-in checks each name's descriptor from the object that listed it, so a
  proxy that did not list a name does not hide an inherited one.
- An Array subclass constructed with a proxy newTarget runs the proxy's get
  trap before any revoked inner proxy is reached.
- The legacy reflect.find reads its lists without calling proxy traps.
2026-12-01 20:31:33 -08:00
dotCooCoo 02077bb5a3 Merge main into feat/js-object-set-prototype-of 2026-12-01 20:25:00 -08:00
dotCooCoo 7f10f7aa96 Merge main into feat/scripts-export-autocad 2026-12-01 15:10:18 -08:00
dotCooCoo 9cff79a9ec Merge main into feat/scripts-api-d3-layers-artboards 2026-12-01 15:07:13 -08:00
dotCooCoo c012eb8ee9 Merge main into feat/scripts-pageitem-transforms 2026-12-01 15:00:42 -08:00
.CooCoo 4596f1a8be Merge pull request #10374 from dotCooCoo/fix/swallowed-regression-guards
Tests: guards check the environment, not the output under test
2026-12-01 14:10:23 -08:00
dotCooCoo 21bca75580 JavaScript: format the for-in visit check as rustfmt does
The gate's fmt step failed at b3c1a31: rustfmt with max_width 150 and
use_small_heuristics Max puts the e4x if/else in Interp's for-in step on one
line, and the previous commit wrapped it over five.
2026-12-01 09:50:28 -08:00
dotCooCoo b3c1a31cfa JavaScript: proxy checks follow GetFunctionRealm, subclass order and for-in sources
- A non-object `prototype` on `new.target` walks its bound and proxy chain
  (GetFunctionRealm), so a get trap that revokes the proxy throws a
  TypeError instead of running the constructor.
- A subclassable built-in such as Number no longer unwraps a revoked
  `new.target` before its own argument conversion runs.
- for-in records how many proxies came before the object that first listed
  each name, and the recheck does not ask those proxies for a descriptor, so
  a proxy that did not list a name cannot hide an inherited enumerable one.
- Names from an ownKeys trap take fuel for their code units, and so do the
  names the ownKeys invariant check hashes.
- The DataView argument test expects TypeError for a non-buffer and
  RangeError for a bad offset or length.
2026-12-01 09:06:27 -08:00
dotCooCoo b0dff71845 Merge main into feat/scripts-api-d3-layers-artboards 2026-12-01 09:03:42 -08:00
dotCooCoo 6de89eece9 Merge main into feat/scripts-api-d8b-tracing 2026-12-01 09:00:59 -08:00
dotCooCoo 5530339d99 Merge main into feat/scripts-pageitem-transforms 2026-12-01 09:00:46 -08:00