mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
fix(parsers): preserve format boundaries and query occurrence identity
Normalize parsed facts at their owning boundaries across PE exports and certificates, ELF section names, GPU bundles, IL2CPP generic types, dyld slice selection, source maps, environment replay, and JavaScript mapped arguments. Preserve partial facts and explicit unsupported cases; clarify the corresponding documentation. Validation: 831 affected tests passed with one existing skip across 23 files; build, typecheck/lint, documentation, formatting, and 2133-file test discovery passed. Format controls are synthetic; real Unity, GPU, and ARM-device execution is unverified. Fixes #6709 Fixes #6688 Fixes #6719 Fixes #6718 Fixes #6704 Fixes #6703 Fixes #6692 Fixes #6723 Fixes #6687 Fixes #6726 Fixes #6696 Fixes #6691 Fixes #6727
This commit is contained in:
1 parent
4193bc5bf8
commit
5f702dd6cc
60 files changed
+2069
-211
No files matched your search
@@ -1,6 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { analyzeJavaScriptSemantics } from "./javascriptSemanticAnalysis.js";
|
||||
import {
|
||||
analyzeJavaScriptSemantics,
|
||||
analyzeParsedJavaScriptSemantics,
|
||||
} from "./javascriptSemanticAnalysis.js";
|
||||
import { parseJavaScriptSource } from "./javascriptSourceParser.js";
|
||||
import {
|
||||
onlyCallable,
|
||||
topLevelBinding,
|
||||
@@ -411,6 +415,69 @@ describe("JavaScript semantic analysis: dataflow 2", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("JavaScript semantic analysis: mapped arguments writes", () => {
|
||||
const commonJs = (source: string) => {
|
||||
const parsed = parseJavaScriptSource(source, "mapped-arguments.cjs");
|
||||
if (parsed === null) throw new Error("Expected CommonJS fixture to parse");
|
||||
return analyzeParsedJavaScriptSemantics(parsed);
|
||||
};
|
||||
const returnField = (source: string) => {
|
||||
const value = onlyCallable(commonJs(source), "read").returnSites[0]?.value;
|
||||
if (value?.status !== "object")
|
||||
throw new Error("Expected an object return value");
|
||||
const field = value.properties.find(({ name }) => name === "value");
|
||||
if (field === undefined) throw new Error("Expected returned value field");
|
||||
return field.value;
|
||||
};
|
||||
|
||||
it.each([
|
||||
["direct arguments write", "arguments[0] = 2;"],
|
||||
["stable arguments alias write", "const args = arguments; args[0] = 2;"],
|
||||
["array assignment pattern write", "[arguments[0]] = [2];"],
|
||||
[
|
||||
"nested object assignment pattern write",
|
||||
"({ nested: arguments[0] } = { nested: 2 });",
|
||||
],
|
||||
])("does not retain a stale literal after a %s", (_name, write) => {
|
||||
expect(
|
||||
returnField(
|
||||
`function read(value) { value = 1; ${write} return { value }; }`,
|
||||
).status,
|
||||
).not.toBe("literal");
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
"strict function",
|
||||
'function read(value) { "use strict"; value = 1; arguments[0] = 2; return { value }; }',
|
||||
],
|
||||
[
|
||||
"default parameter",
|
||||
"function read(value = 0) { value = 1; arguments[0] = 2; return { value }; }",
|
||||
],
|
||||
[
|
||||
"no arguments write",
|
||||
"function read(value) { value = 1; return { value }; }",
|
||||
],
|
||||
])("keeps the independent parameter value for a %s", (_name, fn) => {
|
||||
expect(returnField(fn)).toEqual({ status: "literal", value: 1 });
|
||||
});
|
||||
|
||||
it("retains uncertainty when source mode cannot establish sloppy semantics", () => {
|
||||
const parsed = parseJavaScriptSource(
|
||||
"function read(value) { value = 1; arguments[0] = 2; return { value }; }",
|
||||
);
|
||||
if (parsed === null) throw new Error("Expected fixture to parse");
|
||||
const value = onlyCallable(analyzeParsedJavaScriptSemantics(parsed), "read")
|
||||
.returnSites[0]?.value;
|
||||
if (value?.status !== "object")
|
||||
throw new Error("Expected an object return value");
|
||||
expect(
|
||||
value.properties.find(({ name }) => name === "value")?.value.status,
|
||||
).not.toBe("literal");
|
||||
});
|
||||
});
|
||||
|
||||
describe("primitive addition values", () => {
|
||||
it.each([
|
||||
["true + 1", 2],
|
||||
|
||||
Reference in new issue
Block a user