--export=all exports the module's variables, not a function's locals - #394
Merged
Merged
Conversation
ASDAlexander77
force-pushed
the
export-all-accessor-locals
branch
from
September 28, 2026 15:06
667a445 to
3339035
Compare
An --export filter such as `all` matched every variable statement, function bodies included, so a library's __decls declared each local of each function, method and accessor as a `@dllimport` global in a `.f_<function>` namespace - symbols no library defines. `export` cannot be written inside a function; the filters now apply only where there is no function (the module and its namespaces). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77
force-pushed
the
export-all-accessor-locals
branch
from
September 28, 2026 16:37
3339035 to
853784a
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.
With
--export=all(or any--exportfilter matching a local's name), a library's__declsdeclared every local variable of every function, method and accessor as a@dllimportglobal, in a.f_<function>namespace:No library defines those symbols. I found this in #391's investigation.
Cause: in
mlirGen(VariableDeclarationList), the filters (getExportModifier) were applied to every variable statement, function bodies included.exportcan't be written inside a function, so only a filter could mark a local, and it did.Fix: the filters apply only where there's no function (
!genContext.funcOp), which means the module and its namespaces. Line 965 of the same function already uses that test to mean "module level". A module-level variable is still exported under--export=all, and a namespace'sexport conststill is.Test:
test-compile-export-all-no-localscompilesexport-all/locals.ts(a getter, a method and a function with locals, plus a module-levellet) with--export=all --emit=mlir. It must showlet moduleLeveland nonamespace .f_. It fails without the fix.Results: the suite passes locally, 3012/3012. DefaultLib builds with
--export=none, so it's unaffected.🤖 Generated with Claude Code