Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link: support exporting constant values without a Decl #17735

Merged
merged 2 commits into from
Oct 27, 2023
Merged

Conversation

andrewrk
Copy link
Member

The main motivating change here is to prevent the creation of a fake Decl object by the frontend in order to @export() a value.

Instead, link.updateDeclExports is renamed to link.updateExports and accepts a tagged union which can be either a Decl.Index or a InternPool.Index.

With this, the only remaining calls to startAnonDecl() are for comptime value mutation:

$ grep -RI startAnonDecl ../src
../src/Sema.zig:    pub fn startAnonDecl(block: *Block) !WipAnonDecl {
../src/Sema.zig:    var anon_decl = try block.startAnonDecl(); // TODO: comptime value mutation without Decl
../src/Sema.zig:        var anon_decl = try block.startAnonDecl(); // TODO: comptime value mutation without Decl
../src/Sema.zig:    var anon_decl = try block.startAnonDecl(); // TODO: comptime value mutation without Decl

`.unneeded` source location should never be passed when the source
location is in fact available.
The main motivating change here is to prevent the creation of a fake
Decl object by the frontend in order to `@export()` a value.

Instead, `link.updateDeclExports` is renamed to `link.updateExports` and
accepts a tagged union which can be either a Decl.Index or a
InternPool.Index.
@andrewrk andrewrk requested a review from kubkon October 27, 2023 03:46
@andrewrk andrewrk merged commit 1c85b0a into master Oct 27, 2023
10 checks passed
@andrewrk andrewrk deleted the export-anon branch October 27, 2023 19:20
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