Skip to content

Function only called at comptime is emitted to binary #11152

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
Vexu opened this issue Mar 13, 2022 · 1 comment
Closed

Function only called at comptime is emitted to binary #11152

Vexu opened this issue Mar 13, 2022 · 1 comment
Labels
frontend Tokenization, parsing, AstGen, Sema, and Liveness. stage1 The process of building from source via WebAssembly and the C backend.

Comments

@Vexu
Copy link
Member

Vexu commented Mar 13, 2022

Both stage1 and stage2 will emit an error for foo because they try to emit is as a runtime function even though it is only ever used at comptime.

fn foo() void {
    var a = false;
    if (a) @compileError("analyzed as runtime");
}
comptime {
    _ = foo();
}
@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. stage1 The process of building from source via WebAssembly and the C backend. labels Mar 13, 2022
@Vexu Vexu added this to the 0.10.0 milestone Mar 13, 2022
@andrewrk andrewrk removed the bug Observed behavior contradicts documented or intended behavior label Mar 13, 2022
@andrewrk
Copy link
Member

andrewrk commented Mar 13, 2022

Duplicate of #6256.

Related:

Note that emitting a runtime version of the function makes it available for debuggers.

@Vexu Vexu removed this from the 0.10.0 milestone Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Tokenization, parsing, AstGen, Sema, and Liveness. stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

2 participants