mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 19:44:26 +08:00
fix(javascript): keep CommonJS wrapper redeclarations from inventing application owners (#12084)
fix(javascript): keep wrapper redeclarations from inventing application owners A top-level lexical declaration that reuses a CommonJS wrapper parameter cannot evaluate, and its recovered syntax is complete. Counting that diagnostic as dropped syntax marked the entrypoint as an unexamined loader and erased another package's proven loadFile root. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
Cursor Agent
morluto
parent
31aaec6b4f
commit
ffae857c20
@@ -160,6 +160,30 @@ it("retains typed examination limits alongside successfully parsed source", () =
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps a CommonJS wrapper redeclaration out of recovered-syntax coverage", () => {
|
||||
const source =
|
||||
"const require={main:{require(){}}};require.main.require('../shared/window.cjs');";
|
||||
const file = parseJavaScriptSource(source, "a/main.cjs");
|
||||
expect(file).not.toBeNull();
|
||||
expect(file!.errors).toEqual([
|
||||
expect.objectContaining({
|
||||
reasonCode: "CommonJsWrapperLexicalDeclaration",
|
||||
}),
|
||||
]);
|
||||
const result = analyzeParsedJavaScriptStaticSource(source, file!);
|
||||
expect(result.parse_status).toBe("complete");
|
||||
expect(result.parse_error_count).toBe(0);
|
||||
expect(result.references).toEqual([]);
|
||||
expect(result.analysis_coverage).toMatchObject({
|
||||
syntax: { status: "complete", error_count: 0 },
|
||||
semantics: {
|
||||
unknown_findings: 0,
|
||||
uncertainty: ["commonjs-wrapper-redeclaration"],
|
||||
},
|
||||
examination: { status: "complete" },
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves the legacy summary responsibility without relabeling independent limitations", () => {
|
||||
const base = analyzeJavaScriptStaticSource(
|
||||
"export const value = 1;",
|
||||
|
||||
Reference in New Issue
Block a user