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

incorrect error: exported enum value must be declared extern #9498

Closed
Jarred-Sumner opened this issue Jul 31, 2021 · 1 comment
Closed

incorrect error: exported enum value must be declared extern #9498

Jarred-Sumner opened this issue Jul 31, 2021 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@Jarred-Sumner
Copy link
Contributor

If you export an enum, you get this message:

./src/javascript/jsc/bindings/exports.zig:721:22: error: exported enum value must be declared extern
    @export(ErrorCode.ParserErrorCode, .{ .name = "Zig_ErrorCodeParserError" });
                     ^

If you follow the suggestion in the above error, you get an error that enums cannot be extern

/Users/jarred/Code/esdev/src/javascript/jsc/bindings/exports.zig:110:23: error: enums do not support 'packed' or 'extern'; instead provide an explicit integer tag type
pub const ErrorCode = extern enum(ErrorCodeInt) {
                      ^

This feels like a bug, maybe in AST check or maybe in @export.

For now, I can work around this with an @enumToInt:

    pub const ParserErrorCode = @enumToInt(ErrorCode.from(error.ParserError));
@tauoverpi
Copy link
Sponsor Contributor

Extern enums were removed from the language #2115 (comment) so the error message itself is wrong.

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Aug 6, 2021
@Vexu Vexu added this to the 0.9.0 milestone Aug 6, 2021
@andrewrk andrewrk removed the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Nov 26, 2021
@andrewrk andrewrk changed the title ast-check breaks exporting enums? incorrect error: exported enum value must be declared extern Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

4 participants