Skip to content

Implement @typeId #19861

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

Closed
wants to merge 1 commit into from
Closed

Conversation

SuperAuguste
Copy link
Contributor

Implementation for #19858 if approved. Uses the InternPool.Index, but can be modified to not expose the InternPool.Index via a AutoArrayHashMapUnmanaged(InternPool.Index, void) for example.

@andrewrk
Copy link
Member

OK noted. I will prioritize that proposal since you opened this PR.


const ty = try sema.resolveType(block, ty_src, extra.operand);

return sema.mod.intRef(Type.u32, @intFromEnum(ty.ip_index));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a comptime value? Will this be stable across compiler runs?

Copy link
Contributor Author

@SuperAuguste SuperAuguste Jul 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is a comptime value. I believe it will be stable across compiler runs with this implementation (as long as you're compiling the same source with the same options), but a proposal will have to figure out whether or not the @typeIds should even be the same across runs, and if so, how.

(The current implementation is of course not guaranteed to produce the same @typeIds as the compiler becomes parallelized.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its comptime then it will need to be stable across all compiler runs ever, because again we'd have nondeterminism in the language. If its runtime, this can be side stepped and made implementation-defined behavior (because it only needs to be stable across compiler runs & it can change across versions).

Maybe this seems like an arbitrary distinguishment, but I think it's right that returning an undefined value at runtime is fine.

@Snektron
Copy link
Collaborator

With the ongoing parallelization of the compiler it would be nice if there was some test that the ID remains stable across compilations to avoid nondeterministic builds.

@andrewrk
Copy link
Member

draft status, no updates in 30+ days

@andrewrk andrewrk closed this Oct 15, 2024
@andrewrk
Copy link
Member

Proposal was rejected

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.

3 participants