From 8d1c627e0444444149d9ae4e8499c96cd7635b16 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 3 Nov 2026 08:13:21 -0500 Subject: [PATCH] hybrid --dir: baseline uses repo-relative paths; add test:hybrid-wide, two new findings Baseline identifiers were absolute paths tied to one machine's checkout location, so every known failure would read as fresh anywhere else - fixed to repo-relative, matching test/ts-baseline.txt's convention. test:hybrid-wide runs the three narrow conformance dirs plus the grep- filtered compiler dir against a committed baseline (test/hybrid-wide-baseline.txt, 118 known failures); test:hybrid-widest adds the unbaselined ~/Developer sweep, same relationship test:wide has to test:ts. Two new real-corpus findings from the compiler sweep: importeq-asi-leak-onto-declare (the declare-enum-asi-leak bug survives for import=/export= even though the enum case was fixed by main) and namespace-ambient-member-unqualified-reference (an ambient namespace member referenced by bare name throws ReferenceError in hybrid output; tsc always qualifies it through the namespace object instead) - the latter accounts for most of the compiler sweep's failures. --- corpus/hybrid-findings.jsonl | 2 + notes/hybrid-oracle.md | 37 +++++++++++ package.json | 3 +- test/hybrid-wide-baseline.txt | 118 ++++++++++++++++++++++++++++++++++ test/hybrid.mjs | 15 ++++- 5 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 test/hybrid-wide-baseline.txt diff --git a/corpus/hybrid-findings.jsonl b/corpus/hybrid-findings.jsonl index 83d4dd4..ee01cad 100644 --- a/corpus/hybrid-findings.jsonl +++ b/corpus/hybrid-findings.jsonl @@ -1,2 +1,4 @@ {"name":"namespace-merge-var-class-collision","category":"namespace","src":"namespace A { export class Point { x = 1; } }\nnamespace A { export class Point { y = 2; } }\nexport const out = new A.Point();\n","note":"hybrid output throws SyntaxError: Identifier 'Point' has already been declared. The second merge block's IIFE both destructures the already-merged Point back in and redeclares class Point in the same scope. See notes/hybrid-oracle.md, Real-corpus findings."} {"name":"namespace-merge-missing-member","category":"namespace","src":"namespace A { export namespace B { export let x = 1; } }\nnamespace A { export namespace B { x = 2; } }\nexport const out = A.B.x;\n","note":"ts.transpileModule gives out=2 (the second block's assignment lands on the same B); hybrid gives out=1, the first block's stale value. See notes/hybrid-oracle.md, Real-corpus findings."} +{"name":"importeq-asi-leak-onto-declare","category":"importeq","src":"export import test1 = pack1.test1;\n\ndeclare namespace mod1 { const z: string; }\n","note":"strip mode blanks the declare namespace line to plain spaces; hybrid blanks it to ';' + spaces. Same bug class as the now-fixed declare-enum-asi-leak, but for import=/export= instead of enum. See notes/hybrid-oracle.md, Real-corpus findings."} +{"name":"namespace-ambient-member-unqualified-reference","category":"namespace","src":"namespace N {\n export declare var a: number;\n export var b = a;\n}\nexport const out = N.b;\n","note":"ts.transpileModule qualifies the reference to the ambient member as N.a (undefined, no throw); hybrid leaves the bare 'a' reference, which throws ReferenceError since nothing declares it locally. The most common failure class in the vendor/TypeScript/tests/cases/compiler --dir sweep. See notes/hybrid-oracle.md, Real-corpus findings."} diff --git a/notes/hybrid-oracle.md b/notes/hybrid-oracle.md index 3545a9d..c1c4d4a 100644 --- a/notes/hybrid-oracle.md +++ b/notes/hybrid-oracle.md @@ -365,6 +365,43 @@ engine (`lite/`/`zena/`), written up here for the reviewer; nothing in merge blocks' `B` IIFEs aren't threading the same live binding the way `tsc`'s emission does. +- **`importeq-asi-leak-onto-declare`** — a narrower survivor of + `declare-enum-asi-leak` above: that one (an `enum` before the blanked + `declare` block) was fixed by main's `lite/strip.zena` changes, but the + same leak still happens when an `import =`/`export =` statement (not an + `enum`) is what precedes the blanked `declare namespace`. Found via + `--dir` on `internalModules/moduleDeclarations/ + reExportAliasMakesInstantiated.ts`; minimized: + ```ts + export import test1 = pack1.test1; + + declare namespace mod1 { const z: string; } + ``` + Strip blanks the `declare namespace` line to plain spaces; hybrid blanks + it to `;` + spaces — same length and position, differing only in + character content, same as the enum case before it was fixed. + +- **`namespace-ambient-member-unqualified-reference`** — the most common + failure in the `compiler` sweep by far (most of its `ReferenceError` + failures are this). A namespace member declared `declare` (ambient — no + runtime value, no local binding anywhere) is referenced *by bare name* + from another statement in the same namespace. `tsc` always qualifies such + a reference through the namespace object (`N.a`, reading `undefined`, + not throwing) because it knows the bare name has no local binding to + resolve to; hybrid leaves the bare reference as-is, which throws + `ReferenceError` since nothing in its down-level IIFE ever declares that + name. Minimized, from `assignmentCompatability32.ts`: + ```ts + namespace N { + export declare var a: number; + export var b = a; + } + export const out = N.b; + ``` + Reference: evaluates fine (`N.b` is `undefined`, read through + `N.a` which is also `undefined`). Hybrid: throws `ReferenceError: a is + not defined` evaluating `var b = a;` inside `N`'s IIFE. + - ~~**`asi-module-keyword-identifier`**~~ — **fixed upstream, no longer reproduces.** Originally: `module` used as a plain identifier (not a module declaration) immediately before `in {}` got misidentified and diff --git a/package.json b/package.json index 98b6063..30d2a62 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "test": "npm run build && npm run test:semantic && npm run test:hybrid && npm run test:sucrase", "test:ts": "SEMANTIC_BASELINE=test/ts-baseline.txt node test/semantic.mjs vendor/TypeScript", "test:hybrid": "node test/hybrid.mjs", - "test:hybrid-wide": "node test/hybrid.mjs --dir vendor/TypeScript/tests/cases/conformance/enums --dir vendor/TypeScript/tests/cases/conformance/internalModules --dir vendor/TypeScript/tests/cases/conformance/classes/constructorDeclarations --baseline test/hybrid-wide-baseline.txt && node test/hybrid.mjs --dir vendor/TypeScript/tests/cases/compiler --grep \"enum|namespace|module |public |private |protected |readonly \" --baseline test/hybrid-wide-baseline.txt && node test/hybrid.mjs --dir ~/Developer --grep \"enum|namespace|module |public |private |protected |readonly \" --baseline test/hybrid-wide-baseline.txt" + "test:hybrid-wide": "node test/hybrid.mjs --dir vendor/TypeScript/tests/cases/conformance/enums --dir vendor/TypeScript/tests/cases/conformance/internalModules --dir vendor/TypeScript/tests/cases/conformance/classes/constructorDeclarations --dir vendor/TypeScript/tests/cases/compiler --grep \"enum|namespace|module |public |private |protected |readonly \" --baseline test/hybrid-wide-baseline.txt", + "test:hybrid-widest": "npm run -s test:hybrid-wide && node test/hybrid.mjs --dir ~/Developer --grep \"enum|namespace|module |public |private |protected |readonly \"" }, "devDependencies": { "binaryen": "131.0.0-nightly.20260721", diff --git a/test/hybrid-wide-baseline.txt b/test/hybrid-wide-baseline.txt new file mode 100644 index 0000000..6bdb86d --- /dev/null +++ b/test/hybrid-wide-baseline.txt @@ -0,0 +1,118 @@ +vendor/TypeScript/tests/cases/compiler/ambientConstLiterals.ts +vendor/TypeScript/tests/cases/compiler/arrayBestCommonTypes.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability16.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability17.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability2.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability25.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability26.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability27.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability28.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability29.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability30.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability31.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability32.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability33.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability34.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability35.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability36.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability37.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability38.ts +vendor/TypeScript/tests/cases/compiler/assignmentCompatability4.ts +vendor/TypeScript/tests/cases/compiler/augmentExportEquals1.ts::file3.ts +vendor/TypeScript/tests/cases/compiler/augmentExportEquals1_1.ts::file3.ts +vendor/TypeScript/tests/cases/compiler/augmentExportEquals2.ts::file3.ts +vendor/TypeScript/tests/cases/compiler/augmentExportEquals2_1.ts::file3.ts +vendor/TypeScript/tests/cases/compiler/collisionCodeGenModuleWithMemberClassConflict.ts +vendor/TypeScript/tests/cases/compiler/collisionCodeGenModuleWithModuleReopening.ts +vendor/TypeScript/tests/cases/compiler/collisionCodeGenModuleWithPrivateMember.ts +vendor/TypeScript/tests/cases/compiler/commentsExternalModules.ts::commentsExternalModules_0.ts +vendor/TypeScript/tests/cases/compiler/commentsExternalModules2.ts::commentsExternalModules2_0.ts +vendor/TypeScript/tests/cases/compiler/commentsExternalModules3.ts::commentsExternalModules2_0.ts +vendor/TypeScript/tests/cases/compiler/commentsModules.ts +vendor/TypeScript/tests/cases/compiler/computedEnumMemberSyntacticallyString.ts +vendor/TypeScript/tests/cases/compiler/computedEnumMemberSyntacticallyString2.ts::./foo.ts +vendor/TypeScript/tests/cases/compiler/constEnumErrors.ts +vendor/TypeScript/tests/cases/compiler/constEnumNamespaceReferenceCausesNoImport2.ts::reexport.ts +vendor/TypeScript/tests/cases/compiler/constructorArgsErrors2.ts +vendor/TypeScript/tests/cases/compiler/declFileExportAssignmentImportInternalModule.ts +vendor/TypeScript/tests/cases/compiler/declFileImportChainInExportAssignment.ts +vendor/TypeScript/tests/cases/compiler/declFileTypeAnnotationTypeAlias.ts +vendor/TypeScript/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeAlias.ts +vendor/TypeScript/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorTypeLiteral.ts +vendor/TypeScript/tests/cases/compiler/declFileTypeAnnotationVisibilityErrorVariableDeclaration.ts +vendor/TypeScript/tests/cases/compiler/declFileTypeofModule.ts +vendor/TypeScript/tests/cases/compiler/declFileWithExtendsClauseThatHasItsContainerNameConflict.ts +vendor/TypeScript/tests/cases/compiler/declarationEmitImportInExportAssignmentModule.ts +vendor/TypeScript/tests/cases/compiler/declarationEmitNameConflicts2.ts +vendor/TypeScript/tests/cases/compiler/declarationEmitNameConflicts3.ts +vendor/TypeScript/tests/cases/compiler/declarationFilesGeneratingTypeReferences.ts::/a/app.ts +vendor/TypeScript/tests/cases/compiler/duplicateIdentifiersAcrossContainerBoundaries.ts +vendor/TypeScript/tests/cases/compiler/duplicateIdentifiersAcrossFileBoundaries.ts::file2.ts +vendor/TypeScript/tests/cases/compiler/enumNumbering1.ts +vendor/TypeScript/tests/cases/compiler/enumWithComputedMember.ts +vendor/TypeScript/tests/cases/compiler/es6ExportEqualsInterop.ts::main.ts +vendor/TypeScript/tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts::es6ImportNamedImportInIndirectExportAssignment_1.ts +vendor/TypeScript/tests/cases/compiler/es6ModuleInternalNamedImports.ts +vendor/TypeScript/tests/cases/compiler/es6ModuleInternalNamedImports2.ts +vendor/TypeScript/tests/cases/compiler/escapedIdentifiers.ts +vendor/TypeScript/tests/cases/compiler/exportAlreadySeen.ts +vendor/TypeScript/tests/cases/compiler/exportAssignmentError.ts::exportEqualsModule_A.ts +vendor/TypeScript/tests/cases/compiler/exportAssignmentInternalModule.ts::exportAssignmentInternalModule_A.ts +vendor/TypeScript/tests/cases/compiler/exportAssignmentWithImportStatementPrivacyError.ts +vendor/TypeScript/tests/cases/compiler/exportDeclarationForModuleOrEnumWithMemberOfSameName.ts +vendor/TypeScript/tests/cases/compiler/exportDeclarationInInternalModule.ts +vendor/TypeScript/tests/cases/compiler/exportDefaultClassInNamespace.ts +vendor/TypeScript/tests/cases/compiler/exportImportCanSubstituteConstEnumForValue.ts +vendor/TypeScript/tests/cases/compiler/exportPrivateType.ts +vendor/TypeScript/tests/cases/compiler/forwardRefInEnum.ts +vendor/TypeScript/tests/cases/compiler/fuzzy.ts +vendor/TypeScript/tests/cases/compiler/genericMergedDeclarationUsingTypeParameter.ts +vendor/TypeScript/tests/cases/compiler/genericMergedDeclarationUsingTypeParameter2.ts +vendor/TypeScript/tests/cases/compiler/gettersAndSetters.ts +vendor/TypeScript/tests/cases/compiler/giant.ts +vendor/TypeScript/tests/cases/compiler/globalIsContextualKeyword.ts +vendor/TypeScript/tests/cases/compiler/importOnAliasedIdentifiers.ts +vendor/TypeScript/tests/cases/compiler/internalAliasWithDottedNameEmit.ts +vendor/TypeScript/tests/cases/compiler/intrinsics.ts +vendor/TypeScript/tests/cases/compiler/isolatedDeclarationErrorsObjects.ts +vendor/TypeScript/tests/cases/compiler/missingFunctionImplementation.ts +vendor/TypeScript/tests/cases/compiler/modifiersInObjectLiterals.ts +vendor/TypeScript/tests/cases/compiler/moduleAugmentationDeclarationEmit2.ts::observable.ts +vendor/TypeScript/tests/cases/compiler/moduleAugmentationDisallowedExtensions.ts::x.ts +vendor/TypeScript/tests/cases/compiler/moduleAugmentationExtendFileModule2.ts::observable.ts +vendor/TypeScript/tests/cases/compiler/moduleAugmentationGlobal7.ts +vendor/TypeScript/tests/cases/compiler/moduleAugmentationGlobal7_1.ts +vendor/TypeScript/tests/cases/compiler/moduleAugmentationGlobal8.ts +vendor/TypeScript/tests/cases/compiler/moduleAugmentationGlobal8_1.ts +vendor/TypeScript/tests/cases/compiler/moduleKeywordDeprecated.ts::foo.ts +vendor/TypeScript/tests/cases/compiler/moduleUnassignedVariable.ts +vendor/TypeScript/tests/cases/compiler/multipleExports.ts +vendor/TypeScript/tests/cases/compiler/multivar.ts +vendor/TypeScript/tests/cases/compiler/narrowedImports.ts::/x.ts +vendor/TypeScript/tests/cases/compiler/overloadResolutionOverNonCTObjectLit.ts +vendor/TypeScript/tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass.ts::privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts +vendor/TypeScript/tests/cases/compiler/privacyCheckTypeOfInvisibleModuleError.ts +vendor/TypeScript/tests/cases/compiler/privacyCheckTypeOfInvisibleModuleNoError.ts +vendor/TypeScript/tests/cases/compiler/privacyGloImport.ts +vendor/TypeScript/tests/cases/compiler/privacyGloVar.ts +vendor/TypeScript/tests/cases/compiler/privacyImport.ts +vendor/TypeScript/tests/cases/compiler/privacyLocalInternalReferenceImportWithExport.ts +vendor/TypeScript/tests/cases/compiler/privacyLocalInternalReferenceImportWithoutExport.ts +vendor/TypeScript/tests/cases/compiler/privacyVar.ts +vendor/TypeScript/tests/cases/compiler/privacyVarDeclFile.ts::privacyVarDeclFile_GlobalFile.ts +vendor/TypeScript/tests/cases/compiler/privacyVarDeclFile.ts::privacyVarDeclFile_externalModule.ts +vendor/TypeScript/tests/cases/compiler/structuralTypeInDeclareFileForModule.ts +vendor/TypeScript/tests/cases/compiler/thisBinding.ts +vendor/TypeScript/tests/cases/compiler/this_inside-enum-should-not-be-allowed.ts +vendor/TypeScript/tests/cases/compiler/unusedIdentifiersConsolidated1.ts +vendor/TypeScript/tests/cases/compiler/unusedInterfaceinNamespace5.ts +vendor/TypeScript/tests/cases/compiler/varBlock.ts +vendor/TypeScript/tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedAndNonExportedClassesOfTheSameName.ts +vendor/TypeScript/tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts +vendor/TypeScript/tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts +vendor/TypeScript/tests/cases/conformance/internalModules/codeGeneration/nameCollision.ts +vendor/TypeScript/tests/cases/conformance/internalModules/exportDeclarations/ExportVariableOfGenericTypeWithInaccessibleTypeAsTypeArgument.ts +vendor/TypeScript/tests/cases/conformance/internalModules/moduleBody/moduleWithStatementsOfEveryKind.ts +vendor/TypeScript/tests/cases/conformance/internalModules/moduleDeclarations/invalidInstantiatedModule.ts +vendor/TypeScript/tests/cases/conformance/internalModules/moduleDeclarations/nestedModules.ts +vendor/TypeScript/tests/cases/conformance/internalModules/moduleDeclarations/reExportAliasMakesInstantiated.ts diff --git a/test/hybrid.mjs b/test/hybrid.mjs index 25d65fa..6857092 100644 --- a/test/hybrid.mjs +++ b/test/hybrid.mjs @@ -734,13 +734,22 @@ async function dirMode(dirs, { grep, baseline, write, minutes = 20 } = {}) { console.log("oxidase: not available, skipped"); } + // Baseline identifiers are relative to the repo root, like + // test/ts-baseline.txt's, not absolute — an absolute path is tied to one + // machine's (or one worktree's) checkout location and would never match + // on another, silently turning every known failure "fresh" there. + const relName = (n) => { + const [filePath, segment] = n.split("::"); + const rel = path.relative(root, filePath); + return segment ? `${rel}::${segment}` : rel; + }; if (write && baseline) { - fs.writeFileSync(baseline, failures.map(([n]) => n).sort().join("\n") + "\n"); + fs.writeFileSync(baseline, failures.map(([n]) => relName(n)).sort().join("\n") + "\n"); } const known = new Set(baseline && fs.existsSync(baseline) ? fs.readFileSync(baseline, "utf8").split("\n").filter(Boolean) : []); - const fresh = failures.filter(([n]) => !known.has(n)); + const fresh = failures.filter(([n]) => !known.has(relName(n))); if (baseline) { - const failingNow = new Set(failures.map(([n]) => n)); + const failingNow = new Set(failures.map(([n]) => relName(n))); const fixed = [...known].filter((n) => !failingNow.has(n)); console.log(`baseline ${path.relative(root, baseline)}: ${known.size} known, ${fresh.length} new, ${fixed.length} now passing${fixed.length ? " (shrink the baseline)" : ""}`); } -- knotmirror 0.0.1