Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions TSLANG_ISSUES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2106,3 +2106,47 @@ What remains of the tsc-clean failures is mostly the default library's (`Object.
object literal, properties added to a function, a `never` tslang computes, declared-function overloads).

Tests: diagnostic-location `generic_construct_signature_type_literal.ts`.

152 (keys known only at run time, 2026-11-21; USER DECISIONS: a string index signature is a dictionary, an absent key
reads `T | undefined`, under -mm=own the dictionary owns its values). Fixed:
- `{ [key: string]: T }`, a string index signature and nothing else, is the default library's `ObjectDictionary<T>`
(`@dictionary`, TypeScriptCompilerDefaultLib #114): entries by key known at run time, in the order they were added.
Before, it was a record of `get`/`set` functions nothing could fill: `const d: { [k: string]: number } = { a: 1 }`
was "field "get" can't be found in tuple '{a:s32}'".
- `d[k]`, `d["name"]` and `d.name` of a dictionary, outside its own class, are its entries - never its members, so
`d.get` and `d.size` are entries too - read as `T | undefined` (undefined for a key it does not hold) and written as
T. `k in d`, `for...in`, `Object.keys(d)` and `delete d[k]` / `delete d.name` go by its entries.
- An object literal with a key known only at run time (`{ [m]: i }` with `m: string`) makes a dictionary of its values'
type, and so does one given where a dictionary is wanted (`const d: { [k: string]: T } = { a: 1 }`, an argument, a
return). A spread into one copies a record's fields, or a dictionary's entries (the library's
`objectDictionaryAssign`). Before: "a computed property name must be a constant (a literal, or a `const` holding
one), or a well-known symbol". Whether a key is a constant is decided as before: its value's constant, or its
literal type's (an imported `const`, `"a" + "b"` folded).
- A dictionary type given from elsewhere (a `return`'s receiver, a result type found in an earlier pass) is
instantiated again where the literal is made: it may have been instantiated only in an evaluation, and then its
members were generated nowhere ("'ObjectDictionary<si32>.constructor' does not reference a valid function").
- -mm=own: a parameter moved on paths that exclude each other - `if (f) a.push(v); else a[0] = v;`, a move then
`return` and another move after it, a `T | undefined` narrowed once and moved on two paths - was "'v' is used here
after its value was moved" (only one move of a parameter was allowed). Each move empties the parameter, so the
release at the exit, kept for a path that moves nothing, frees nothing on the others; one the function keeps on
every path is reached at each exit only through one of the moves (movesOnExclusivePaths). The dictionary's `set`
needs it. Leak probes, flat at 33 MB: 20M calls moving a parameter on exclusive paths (own), 3M writes,
overwrites and deletes of a dictionary of objects (rc and own).

- Found on the way: a module importing another and using a Map (`import "./a"; new Map<string, boolean>()`)
failed with "'ts.Func' op symbol declaration cannot have public visibility": the keys adapter of the RangeError
the library's Map throws was made while the imported file was read as declarations, a declaration, then made
public. It is made in full there now, as a specialization is (makeAnyKeysAdapter).

Still open, looked at:
- An interface with only a string index signature (`interface Dictionary<T> { [x: string]: T }`) is still an
interface: the dictionary is for the type literal (and so for what is written with it).
- -mm=own: a local moved inside two `if`s one after the other (`if (a) keep(k); if (b) keep(k);`) is "moved here on
some paths only" - so the dictionary copies its keys rather than taking the caller's; a spread of a record into a
dictionary is refused (its fields would have two owners).
- A spread of a dictionary into one of another value type is an error for now: inferring `f<T, S>(a: Box<T>, b:
Box<S>)` from `f(Box<number>, Box<string>)` gives T = number | string and S = any, and the call then reads the
second argument with the wrong layout (a crash) - a generic-inference bug of its own.
- `a[a.length] = x` on an array does not grow it (gc writes past the end; rc and own crash).

Tests: `00object_dictionary.ts`, `00own_param_exclusive_moves.ts` (compile, JIT, rc, own).
7 changes: 7 additions & 0 deletions tslang/include/TypeScript/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,13 @@
// a Shared<T> handle (counted): an object, whose block has one owner, goes through Shared<T>.
// The other memory models ignore it.
#define SHARED_ELEMENTS_DECORATOR "sharedElements"
// `@dictionary class ObjectDictionary<T>`: the value of a string index signature (`{ [key: string]: T }`,
// `{ [k]: v }` with a key known only at run time). Outside the class, `d.name` and `d["name"]` are its
// entries, never its members (ClassInfo::isDictionary).
#define DICTIONARY_DECORATOR "dictionary"
#define OBJECT_DICTIONARY_CLASS_NAME "ObjectDictionary"
// the default library's function a spread of a dictionary into a new one calls
#define OBJECT_DICTIONARY_ASSIGN_NAME "objectDictionaryAssign"
// On a `ts.ThisVirtualSymbolRef` (a method's) or a `ts.VirtualSymbolRef` (an accessor's): the
// receiver's class is @final, but defined in another module, so the call still goes through the
// vtable. The slot holds the method the reference names, which
Expand Down
3 changes: 3 additions & 0 deletions tslang/include/TypeScript/MLIRLogic/MLIRGenStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,9 @@ struct ClassInfo
// else, a slot left to a declared C++ method null), may have a constructor and field
// initializers, and `.new`; still no RTTI. tslang allocates its objects.
bool isCppVTableImplementation = false;
// `@dictionary`: the value of a string index signature. Outside its own methods `d.name`
// and `d["name"]` read and write its entries, not its members.
bool isDictionary = false;
// `@atomic`: its objects may be used by several threads at once. Under -mm=rc a new object is
// marked shared, with everything it holds, once its constructor has run, and a value stored
// into one of its fields is marked before the store (ts.MarkShared), so every block reachable
Expand Down
Loading
Loading