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

Assertion computing source location span of a non-initial multi-prong #22343

Open
jacobly0 opened this issue Dec 29, 2024 · 0 comments
Open

Assertion computing source location span of a non-initial multi-prong #22343

jacobly0 opened this issue Dec 29, 2024 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness.

Comments

@jacobly0
Copy link
Member

comptime {
    switch (@as(enum { x }, .x)) {
        else => {},
        .a, .b => {},
    }
}
$ zig-debug build-obj bug.zig
thread 135248 panic: reached unreachable code
src/Zcu.zig:1701:32: 0x18d5f22 in span (zig)
                        } else unreachable;
                               ^
src/Compilation.zig:3357:42: 0x18e6a7d in addModuleErrorMsg (zig)
    const err_span = try err_src_loc.span(gpa);
                                         ^
src/Compilation.zig:3161:34: 0x18ee64c in getAllErrorsAlloc (zig)
            try addModuleErrorMsg(zcu, &bundle, error_msg.*);
                                 ^
src/Compilation.zig:3288:44: 0x1a375f2 in totalErrorCount (zig)
    var errors = try comp.getAllErrorsAlloc();
                                           ^
src/Compilation.zig:3284:28: 0x18c2ed4 in anyErrors (zig)
    return (totalErrorCount(comp) catch return true) != 0;
                           ^
src/Compilation.zig:2286:18: 0x18b9d6f in update (zig)
    if (anyErrors(comp)) {
                 ^
src/main.zig:4453:20: 0x18f30d7 in updateModule (zig)
    try comp.update(prog_node);
                   ^
src/main.zig:3643:21: 0x1959a21 in buildOutputType (zig)
        updateModule(comp, color, root_prog_node) catch |err| switch (err) {
                    ^
src/main.zig:270:31: 0x17e83e7 in mainArgs (zig)
        return buildOutputType(gpa, arena, args, .{ .build = .Obj });
                              ^
src/main.zig:205:20: 0x17e52e5 in main (zig)
    return mainArgs(gpa, arena, args);
                   ^
lib/std/start.zig:656:37: 0x17e4dee in main (zig)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x7fe92b5fc3ed in ??? (libc.so.6)
Unwind information for `libc.so.6:0x7fe92b5fc3ed` was not available, trace may be incomplete

Aborted (core dumped)
$ zig-release build-obj bug.zig
bug.zig:1:1: error: no field named 'a' in enum 'bug.comptime__enum_156'
comptime {
^~~~~~~~
bug.zig:2:17: note: enum declared here
    switch (@as(enum { x }, .x)) {
                ^~~~~~~~~~
referenced by:
    root: lib/std/start.zig:3:22
    comptime: lib/std/start.zig:27:9
    2 reference(s) hidden; use '-freference-trace=4' to see all references
@jacobly0 jacobly0 added bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. error message This issue points out an error message that is unhelpful and should be improved. labels Dec 29, 2024
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 error message This issue points out an error message that is unhelpful and should be improved. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

1 participant