Skip to content

Report dictionary copies of {} views, and keep method calls direct after writes into dictionaries of dictionaries - #1855

Merged
ctate merged 6 commits into
mainfrom
ctate/report-dictionary-copies-84b5a0
Oct 24, 2026
Merged

ctate merged 6 commits into
mainfrom
ctate/report-dictionary-copies-84b5a0

Conversation

@ctate

@ctate ctate commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1408

…after writes into dictionaries of dictionaries

Fixes #1408
Co-authored-by: Chris Ainsley <c.b.ainsley@gmail.com>
@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 24, 2026 2:34am UTC

Comment thread packages/compiler/src/frontend/lowering/divergences.ts Outdated
Comment thread packages/compiler/src/frontend/lowering/class-method-mutations.ts Outdated
…aries

A record or class instance converted to a string-keyed dictionary type
(`Record<string, V>`, `{ [key: string]: V }`) was copied field by field
into a native dictionary record, directly, through a dictionary parameter,
or through a `{}`, `object` or `unknown` binding or parameter. Writes
through the dictionary missed the original object, and the dictionary was
never `===` to it, where under Node it is the same object.

ClassProtocols now marks a dictionary value type when a dictionary of that
value type receives an existing object (a binding, member, element or
`this` whose type is a program class instance, a record with declared
properties, or a `{}`, `object` or `unknown` binding or parameter that
holds one), and the program writes through, compares or passes to a
whole-object observer a dictionary of that value type. usesCheckedIdentity
answers true for those dictionaries, so they lower to checked-dynamic
storage, which holds the original object. Dictionaries of `unknown` or
`any` values are checked-dynamic already and are not marked.

The dictionary case of SC6001 is removed, since these conversions now keep
the object.
Comment thread packages/compiler/src/frontend/lowering/class-protocols.ts Outdated
Comment thread packages/compiler/src/frontend/lowering/class-protocols.ts
@ctate
ctate merged commit 5c131cb into main Oct 24, 2026
124 of 126 checks passed
@ctate
ctate deleted the ctate/report-dictionary-copies-84b5a0 branch October 24, 2026 03:18

This branch was successfully deployed

1 active deployment
Preview — 43b0f290 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Perf issue storing a dictionary into a record's nested dictionary under a computed key (workaround 144x faster)

1 participant