Skip to content

Fix 3 more not-implemented crashes: import-equals and interface methods - #301

Merged
ASDAlexander77 merged 1 commit into
mainfrom
fix/import-equals-crashes-to-error
Jul 24, 2026
Merged

Fix 3 more not-implemented crashes: import-equals and interface methods#301
ASDAlexander77 merged 1 commit into
mainfrom
fix/import-equals-crashes-to-error

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Continuation of the not-implemented-audit crash-to-error sweep (follow-up to #297-#300), continuing the MLIRGenImpl.h/MLIRGenInterfaces.cpp/MLIRGenTypes.cpp cluster:

  • mlirGenModuleReferenceimport fs = require("fs") crashed: the classic CommonJS/Node-interop import-equals form (a real, easily-reachable pattern in legacy TS code) was never handled. tslang compiles as one flat program with no Node.js-style require() at runtime, so this is now a clean "not supported" error.
  • mlirGen(ImportEqualsDeclaration...)import X = SomeEnum (or any target that isn't a namespace/class/interface) crashed the same way. Fixing the require() crash above surfaced a second, latent bug in the same function: the caller unwrapped the callee's result without checking .failed() first, since the callee previously could only crash or succeed. Added the missing EXIT_IF_FAILED guard.
  • addInterfaceMethod's empty-name guard — already had llvm_unreachable immediately followed by a dead return mlir::failure(), the same pattern as an earlier confirmed-dead case in this audit. Fixed defensively (trivial, location already in scope); reachability not verified with a repro this time.

docs/not-implemented-audit.md updated with the full writeup (§4.11), including a general lesson for the rest of this audit: converting a crash to return mlir::failure() can surface a second bug one level up in a caller that never had to handle a graceful failure before — always re-run the specific repro, not just the full suite.

Test plan

  • Individual repros (import fs = require("fs"), import C = SomeEnum) verified: clean diagnostics, no crash
  • Full suite: ctest -C Debug -j8 → 829/829, no regressions

🤖 Generated with Claude Code

…e methods

- mlirGenModuleReference: `import fs = require("fs")` crashed - the
  function only handled QualifiedName/Identifier module references, never
  ExternalModuleReference (the parser does support this syntax). tslang
  compiles as one flat program with no Node.js-style require() at runtime,
  so this is converted to a clean "not supported" error rather than crash.

- mlirGen(ImportEqualsDeclaration...): `import X = SomeEnum` (or any target
  that isn't a namespace/class/interface) crashed the same way. Fixing the
  require() crash above surfaced a second, latent bug in this same
  function: the caller unwrapped mlirGenModuleReference's result with
  V(result) without ever checking result.failed() first, since the callee
  previously could only crash or succeed. Added the missing
  EXIT_IF_FAILED(result) guard.

- addInterfaceMethod's empty-name guard: already had llvm_unreachable
  immediately followed by a dead `return mlir::failure()` - the same
  "crash-then-already-written-graceful-return" shape as the (confirmed
  dead) UnaryBinLogicalOrHelper.h case earlier in this audit. Fixed
  defensively (trivial one-line swap, location already in scope);
  reachability not verified with a repro this time.

Continues the MLIRGenImpl.h/MLIRGenInterfaces.cpp/MLIRGenTypes.cpp cluster
sweep (docs/not-implemented-audit.md §4.11).

829/829 ctest, no regressions.
@ASDAlexander77
ASDAlexander77 merged commit f89ffb0 into main Jul 24, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix/import-equals-crashes-to-error branch July 24, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant