An import's errors are the importer's to report - #381
Merged
Merged
Conversation
In an import cycle where a class extends one from the other file, the first attempt at the inner import fails: the outer file has not declared the base class yet. processStatements tries the import again and it succeeds, but the import's own mlirDiscoverAllDependencies / mlirCodeGenModule had already printed its errors, so a compile that succeeded printed "can't resolve name" and "failed statement" (BrowserLib Node.ts / TextNode.ts, #231). While an imported source file is generated, outputDiagnostics now collects its errors instead of printing them, and mlirGenInclude re-emits them to the importer's handler. There, a retry that succeeds discards them, and an import that still fails prints them as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
force-pushed
the
fix-import-retry-diagnostics
branch
from
September 28, 2026 08:31
f6923d2 to
70c8715
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A compile that succeeded printed errors when its imports formed a cycle through a class hierarchy. Found in the BrowserLib sources attached to #231:
Node.tsandTextNode.tsimport each other, andTextNode extends Node.Cause
processStatementsruns a failed statement again once the statements after it have been generated, and it discards the errors of an attempt that later succeeds. Animportis one such statement. Whencycle_class_nodeimportscycle_class_text, the first attempt fails becauseNodeis not declared yet, and the next pass succeeds.However,
mlirGenIncludegenerates the imported file with its ownmlirDiscoverAllDependenciesandmlirCodeGenModule. Each of those installs its own diagnostic handler and prints its errors throughoutputDiagnosticsbefore returning failure. By the time the importer decided to retry, the errors were already on the screen.Fix
outputDiagnosticsmoves its errors into a list set up bymlirGenInclude, instead of printing them.mlirGenIncludeemits them again, so they reach the importer's handler.failed statementat theimportline.showMessages) are unchanged.Tests
test-compile-reference-path-import-cycle-quietcompilescycle_class_node.tsand fails if the output containserror:. It fails onmain.test-compile-reference-path-import-cycle-classlinks the cycle into a program that walks the tree throughinstanceof TextNode.test-compile-gc-shared-auto,test-compile-foreign-target-import-errors, and thereference-path-missing*tests.Not in this PR
The same two modules built into one
-sharedlibrary fail for the importer withredefinition of symbol named 'Node..new'. The library declaresNodetwice to whoever imports it, once for each module. This fails the same way onmain, so only the static variant is registered.🤖 Generated with Claude Code