mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
fix(javascript): separate erased types from runtime semantics
Record erasure during definition indexing and reuse it across runtime references, captures, effects, module links, routes, Electron and Vite. Preserve source type links and emitted decorator and computed-key effects; keep actual runtime reads and escapes conservative.
Validation: 1,647 focused tests and 9 documentation tests passed, with build, static and documentation gates. The inherited reference-lifetimes stress file exhausts a 512 MiB worker on both unmodified 18451e479 and this change; that file remains unverified. TypeScript 7.0.2 emit was inspected for ES2022 and ES2018 without executing emitted code.
This commit is contained in:
1 parent
cab78de506
commit
89006609f1
32 files changed
+756
-328
No files matched your search
@@ -58,7 +58,9 @@ import {
|
||||
} from "./javascriptSemanticState.js";
|
||||
import {
|
||||
completeSemanticSteps,
|
||||
isErasedJavaScriptValueChild,
|
||||
traverseJavaScriptAstSteps,
|
||||
traverseJavaScriptValueAstSteps,
|
||||
} from "./javascriptSemanticTraversal.js";
|
||||
import {
|
||||
semanticRequireOrigin,
|
||||
@@ -690,7 +692,7 @@ function* classifyDefinitionReceiversSteps(
|
||||
);
|
||||
if (aliasFact !== undefined) facts.set(node.start ?? -1, aliasFact);
|
||||
};
|
||||
yield* traverseJavaScriptAstSteps(program, {
|
||||
yield* traverseJavaScriptValueAstSteps(program, state.erasedSyntaxNodes, {
|
||||
enter: (node) => {
|
||||
classifyRpcRoot(node);
|
||||
classifyOpenReceiver(node);
|
||||
@@ -897,6 +899,7 @@ export function* indexJavaScriptElectronIdentitySteps(
|
||||
};
|
||||
yield* collectJavaScriptIdentityWritesSteps(
|
||||
program,
|
||||
state.erasedSyntaxNodes,
|
||||
(node, kind) => {
|
||||
if (kind === "opaque-call") return [interop.opaqueMutationPath(node)];
|
||||
const { root, members } = electronMemberPath(node);
|
||||
@@ -922,7 +925,7 @@ export function* indexJavaScriptElectronIdentitySteps(
|
||||
const intactExport = (path: readonly (string | null)[]): boolean =>
|
||||
ELECTRON_MODULE.test(path[0] ?? "") &&
|
||||
!writes.covers(["electron", ...path.slice(1)]);
|
||||
yield* traverseJavaScriptAstSteps(program, {
|
||||
yield* traverseJavaScriptValueAstSteps(program, state.erasedSyntaxNodes, {
|
||||
enter: (node) => {
|
||||
if (
|
||||
!t.isCallExpression(node) &&
|
||||
@@ -1052,6 +1055,7 @@ const createState = (
|
||||
getterResourceLimits: new Set(),
|
||||
returnedReferenceWidenings: new Set(),
|
||||
parentsByNode: new WeakMap(),
|
||||
erasedSyntaxNodes: new WeakSet(),
|
||||
scopes: [root],
|
||||
scopesById: new Map([[root.scopeId, root]]),
|
||||
scopeByNode: new WeakMap([[program, root]]),
|
||||
@@ -1124,6 +1128,13 @@ function* collectDefinitionsSteps(
|
||||
yield* traverseJavaScriptAstSteps(program, {
|
||||
enter: (node, parent, readAncestors) => {
|
||||
if (parent !== null) state.parentsByNode.set(node, parent);
|
||||
if (
|
||||
(parent !== null && state.erasedSyntaxNodes.has(parent)) ||
|
||||
isErasedJavaScriptValueChild(node, parent)
|
||||
) {
|
||||
state.erasedSyntaxNodes.add(node);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
t.isWithStatement(node) ||
|
||||
t.isForInStatement(node) ||
|
||||
@@ -1438,7 +1449,7 @@ function* indexPrototypeUncertaintySteps(
|
||||
"defineProperties",
|
||||
"setPrototypeOf",
|
||||
]);
|
||||
yield* traverseJavaScriptAstSteps(program, {
|
||||
yield* traverseJavaScriptValueAstSteps(program, state.erasedSyntaxNodes, {
|
||||
enter: (node, parent) => {
|
||||
const write = semanticWriteSiteTarget(node);
|
||||
if (write !== null) {
|
||||
|
||||
Reference in new issue
Block a user