The script checker kept a replacement of a variable's methods
(`give(local)`, `local.saveAs = w`) for the body that had declared the
name so far in the text. A `var` statement declares the name for the
whole body, and a parameter is the function's own variable, so the
replacement could count for the wrong variable:
- A function whose own later `var local` or parameter `local` declares
the name no longer ends the exemption of an outer `local`'s own
`saveAs` (`function h(a, local) { return local; }`).
- A replacement now counts for the innermost body around it that
declares the name anywhere in the body, found once every body's
names are known.
- When a body past the nesting limit or out of room for its names is
around the replacement, the declaring body is not known, and the
replacement counts for a variable of that name in every body.
- The call site looks the replacement up for the body that declares
the receiver, walking outward from the innermost body.
The declarations pass recorded a function body or loop replacing a
variable's document write method only for `local.saveAs = ...` and
`local['saveAs'] = ...`. A hoisted function or a later loop pass could
still change the method through a compound or update operator
(`local.saveAs += w`, `local['saveAs']++`), or hold the object under
another name (`var y = local; y.saveAs = w`, `give(local)`), and an
earlier `local.saveAs(f)` kept its exemption.
The pass now reads these the way the main pass reads them: any compound
or update operator on a write method, `++local.saveAs`, a key in brackets
that is not one string or number literal, `delete local`, and the
variable used as a value. Each recorded replacement is kept by the body
that declares the variable, so a function's own variable of the same name
keeps its exemption.
- A loop that assigns `local.saveAs` or `local['saveAs']` marks `local` as assigned in that
loop, so a call earlier in the loop writes a file.
- A function body that replaces a variable's write method, declared anywhere in the file,
ends the exemption for that variable's calls. A variable the innermost body declares
itself is left alone, and a key whose escapes do not decode counts as a write method.
- `$.global.local`, `this.local` and `globalThis.local` used as a value forget the variable's
methods as `$.global['local']` does. A variable of the same name that the function body
declares keeps its own.
- The test with two `a.saveAs(f)` calls puts them on separate lines and checks both.
`var alias = $.global['local']` or `f(this['local'])` may share the
global variable's object, so a later literal's saveAs is no longer the
script's own and its calls are reported as file writes. Adds tests for
that case and for `$.global.local.saveAs = ...` under a parameter named
`local`.
The gate's fmt step failed on a9c8f363: the use lists in analyze.rs and
analyze/features.rs grew past rustfmt's max_width of 150 and were left on
one line. They are now wrapped as cargo fmt writes them.
The script checker stored a bracketed global key such as $.global['name']
cut to 256 characters, so a longer key forgot a different variable and a
later own saveAs call on the real one was not reported. Keys are now
decoded in full. A key whose escape does not decode to one exact name
(\u{63}, a short \x or \u, a lone surrogate) forgets every variable's
own methods instead of one name.
The checker treated `$.global.local.saveAs = …` as replacing the
variable's own saveAs, but missed the bracket forms
`$.global['local'].saveAs = …`, `this['local'].saveAs = …`,
`globalThis['local']['saveAs'] = …` and `$.global.local['saveAs'] = …`,
so a script could rebind a document write method that way and its
later writes were not reported. These forms now end the variable's
own saveAs, including when a function body declares a variable of
the same name.
A property assignment in a loop (`$.global.local = d`, `o['local'] = d`)
may give the global variable `local` another value on the next pass, so a
call of its own `saveAs` earlier in the same loop may save a document. The
check now treats such an assignment as a rebinding of the global variable
in that loop. A key with an escape may name any variable, so every call in
a loop is checked after one.
A function that assigns `$.global.local.saveAs`, `globalThis.local.saveAs`
or `this.local.saveAs` replaces the method of the global variable `local`,
also when the function declares its own `local`, so a later call of
`local.saveAs` is reported. A `global` property of another object
(`holder.global.local`) is not the global object.
Tests whose all() passed on an empty list now check the list's length or
that it is not empty:
- huge_circles_bridge_with_finite_anchors_or_are_refused (pathops bridge)
- smooth_rounds_corners (pathops ops): the four corners stay, smoothed
- a_held_rotation_turns_the_art_around_its_pin (tools ARAP): one point
per mesh vertex
- the_eraser_drag_area_matches_the_release_when_pressure_or_a_mode_starts_during_the_drag
(tools gesture): one released point per press
- every_effect_casts_a_shadow, inflate_cells_across_a_hole_edge_are_cut_to_the_shape,
a_plane_has_only_a_front_and_a_hollow_solid_none and
perspective_runs_0_to_160_degrees_with_the_eye_outside_the_object (three-d)
- a_file_two_branches_include_is_followed_from_the_shallower_one
(scriptcheck): one row per include line
- pens_pick_colors_and_widths (cad HP-GL): four widths
- junk_pressure_brushes_draw_finite_art (brush): all 12 cases draw
Round trips that hold by construction (parse finds the id in ALL) are
replaced with one saved name that must parse and one that must not:
follow_names_parse (pathops shared edge), the shape kinds (pathops
shapes), surfaces_parse_from_their_ids (three-d), the Quick Pen actions
(tools), names_parse_and_serialize_as_names (plugins) and the brush
variation modes, which also compare the serde names with the ids.
crop_keeps_an_instance_whose_art_reaches_the_region (cad) names the
entities written instead of checking that some were.
the_saved_engine_preference_is_found (app) pins the GPU choices the
preferences offer to the three the app reads.
timing_unite_1000_circles (pathops) gets an ignore reason and checks
that Unite gives one shape.
Each changed assertion fails when the code under test is broken (an id
renamed, a list emptied, a flush or instance dropped) and passes when it
is restored.
A function body that assigns `$.global.name`, `globalThis.name` or
`$.global['name']` may run after a later literal gives `name` its methods,
as `this.name` already did. The assignment now records the name as
reassigned later, so the literal's later calls keep reporting the write.
An assignment in the global code runs once and still leaves a later
literal's methods the script's own.
The shadowing test is split so the named-global case and the computed-key
case each check their own line.
- document.open refuses page, cropTo, pages and crop when a named importer reads the file (linkPages
still uses the built-in reader).
- exportFile with explicit null options throws a TypeError for GIF, PNG8 and TIFF too.
- close(SaveOptions.SAVECHANGES) saves a modern .ai or .ait file and an SVG file with Preserve
Editing whatever range was remembered; a range the save refuses still refuses.
- The script checker keeps a try statement's catch and finally, and an else after a nested
do-while, inside the loop body; a line break after a label does not start a new statement; a
this assignment in a function that hides a global clears the global's saved methods; and
holder.d['saveAs'] = ... no longer counts as a write to d.
- docs/mcp.md describes which files keep every artboard on close.
- document.open with an explicit PDFCROPBOX crop opens on the crop box
of a file with editing data; the default keeps the trim box and bleed.
- Closing with save changes keeps an EPS document's artboard range, since
the EPS file holds the whole document.
- The script checker treats a writer receiver captured from an outer
scope as able to change before each call, and finds the loop that holds
a call with a binary search instead of a scan of every loop.
Document.close(SaveOptions.SAVECHANGES) now judges artboard loss by the
file the save writes. A PDF last saved with useArtboards: false is
refused, since it holds one page of the art's bounds. A native or .ai
file saved with separateArtboards is saved and closed whatever its range
names, since the range picks only the separate files; a version 7 .ai
file keeps the range check.
Document.saveAs, Document.exportFile, app.open and the save that
close(SaveOptions.SAVECHANGES) runs write each warning of their command
to the console after the method's name (for example "saveAs: SVG keeps 1
of the document's 2 artboards ...").
Script Check reports a file write for a saveAs or exportFile call on the
script's own object when the variable is assigned in a loop around the
call, since a later iteration may run the call on a document. Loop bodies
without braces follow if, else and line breaks, and a variable of the
same name that a function declares is kept apart.
A test shows that a waiting point change counts as unsaved for
Document.saved and close().
A computed key such as c[k] = w makes the check unsure for the whole
script, so since the last commit every saveAs in that script counts as a
write, the ones before the computed key included. The test put that case
in the same script as the others, so the own saveAs calls it expected to
write nothing were reported. The computed-key case now has its own
script and assertion, and the other cases keep theirs.
main's Document member list held saveAs and close as members that are not
available yet; this branch's save_open members implement them, so the
merge drops them from that list and keeps main's other entries. The
script host test lists take main's members together with this branch's
open, userInteractionLevel, fullName, path, saved and option classes,
and the heap accounting keeps main's ModuleNamespace arm beside the
FsEntry string arm.
- saveAs picks the encoder from the requested name, so a link to a file of
another format writes the format the name asks for.
- fullName, path and close(SaveOptions.SAVECHANGES) resolve a relative saved
path against the working directory.
- close(SAVECHANGES) accepts an artboard range that covers every artboard and
keeps the document open when the save would drop artboards.
- app.open keeps the requested file name, rejects a file over 128 MiB before
reading it, applies the requested color space to plug-in imports, and
rejects PDF options for files that are not PDF content; null PDF options
keep their defaults.
- Explicit null options throw; assigning the current Document.saved value
runs no command; Document.path reflects as Folder or string.
- An implicit multi-file save names no refused path in its error.
- The script checker counts SAVECHANGES only on SaveOptions and keeps write
warnings for receivers that evaluated code can rebind.
A script can pass SaveOptions.SAVECHANGES to a document's close through
a variable that holds SaveOptions, or through a property of an object
that holds it. The check reports any SAVECHANGES member as a file write,
whatever the receiver. A test now covers the alias and member cases, and
a key of the script's own object literal, which is not reported.
A script without includes whose declarations give names values the analysis
does not read came back from its first scan with `Known::unsure` set and no
names. `settle` counted that as something known and scanned the script again,
which found the same and doubled the scan's steps. The proptest
`any_bytes_are_checked_in_linear_work` shrank one such input to 104 bytes that
took 550 steps, over its bound of 536.
`settle` now keeps the first scan when it found no bound names and no File
objects: the flag comes from the script's own declarations, which the first
scan already read.
A script whose only finding about its variables was that a name in
brackets is not one literal (o[k]) was scanned a second time. That
finding comes from the names the script declares, which the first scan
has already read, so the second scan gave the same report and added up
to three steps a byte. A 104-byte input of single-character tokens took
550 steps against the 536 the property test allows.
The check now repeats a scan only when a variable holds a member chain
or a File or Folder object. The property tests take their bound from
the number of scans: five steps a byte for a script scanned once, and
seventeen for one scanned up to five times.