Repository navigation
Merged
Conversation
… of its symbol; a bare @[c_export] is refused (#2554) Root cause: frontend_fn_tier_verdict (src/compiler/Frontend.w) drops a user-import fn that a higher tier names, unless the fn is displaceable, and a c_export fn is not displaceable. The higher-tier name list (root_fn_names) counted the root's `extern fn` declarations, so the root's `extern fn assert_bool` (its view of the C symbol) dropped the module's `@[c_export("assert_bool")]` definition of that symbol; the link failed with `undefined symbol: _assert_bool`. A c_export definition is now checked against the root's DEFINITIONS only (root_defined_fn_names), the rule D30 R2c already applies to the runtime's definitions. And the parser stored a c_export only from `@[c_export("name")]`; a bare `@[c_export]` (or an empty name) exported nothing and said nothing. It is now refused with the §16.5 spelling. Evidence: before behav_2554_c_export_extern_caller.w: ld64.lld: error: undefined symbol: _c2554_bump after 20 30 5 (stage1) before err_2554_bare_c_export.w: check ok after error: `@[c_export]` needs the C name it exports: `@[c_export("name")]` (§16.5) Tests: test/behavior/behav_2554_c_export_{owner,extern_caller}.w, test/compile_errors/err_2554_bare_c_export.w
ehartford
marked this pull request as ready for review
October 25, 2026 20:07
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.
Root cause: frontend_fn_tier_verdict (src/compiler/Frontend.w) drops a
user-import fn that a higher tier names, unless the fn is displaceable, and
a c_export fn is not displaceable. The higher-tier name list
(root_fn_names) counted the root's
extern fndeclarations, so the root'sextern fn assert_bool(its view of the C symbol) dropped the module's@[c_export("assert_bool")]definition of that symbol; the link failedwith
undefined symbol: _assert_bool. A c_export definition is nowchecked against the root's DEFINITIONS only (root_defined_fn_names), the
rule D30 R2c already applies to the runtime's definitions.
And the parser stored a c_export only from
@[c_export("name")]; a bare@[c_export](or an empty name) exported nothing and said nothing. It isnow refused with the §16.5 spelling.
Evidence:
before behav_2554_c_export_extern_caller.w: ld64.lld: error: undefined symbol: _c2554_bump
after 20 30 5 (stage1)
before err_2554_bare_c_export.w: check ok
after error:
@[c_export]needs the C name it exports:@[c_export("name")](§16.5)Tests: test/behavior/behav_2554_c_export_{owner,extern_caller}.w,
test/compile_errors/err_2554_bare_c_export.w
Closes #2554