#Using @TypeOf on error unions
1 messages · Page 1 of 1 (latest)
Is Sorry was second guessing myself. type not a keywordtype is a keyword so you're likely hitting the error because you're shadowing the keyword
You're also not using the variable, so zig will error on that.
pub fn main() void {
const foo = @TypeOf(error.BadValue);
_ = foo;
}```Compiles for me on master
hmmm. still coredumps for me on that program
What version of zig are you using?
Ah, im building from 3cb987f5a575bc5871459805a86640ba1a2d7cae. Im one commit off true master
Don't see how spirv will change much. I was coredumping since a few days ago. Tried updating some more. Only recently got it compiled with debug info.
I'll submit a github bug, was curious if that was invalid though, sounds like it shouldn't be. thanks!
Turns out I'm actually pretty behind as well haha. I thought I updated recently but I must have been imagining things. I'm on 0.12.0-dev.3142+9e402704e. Maybe there was a regression?
Ah maybe. Only started using zig again last week. Last builds I had before that were from ages ago.
https://github.com/ziglang/zig/issues/19506 for posterity
Can you please provide an actual reproduction? The code is missing a semicolon and zig build test.zig is not usually a valid command.
Updated. It is quite literally saving const t = @TypeOf(error.BadValue) as test.zig and doing zig build test.zig
Found it when adding @TypeOf(error union) caused the compiler to segfault on much more complex code
$ zig build test.zig
no step named 'test.zig'
access the help menu with 'zig build -h'
I guess this is more accurate
$ zig build test.zig
info: initialize build.zig template file with 'zig init'
info: see 'zig --help' for more options
error: no build.zig file found, in the current directory or any parent directories
Ohhhh my bad, forgot about build.zig (as I said haven't used zig in a while)
sorry, I legit didn't expect you to have a build step named after a file
anyway I'm still getting the first output, we need the actual command you are running
Maybe you are actually getting a crash in src/main.zig but editing test.zig for example?
Ya im not sure what the build.zig is doing ngl. Going to paste the actual file that I first started coredumping on since I gotta go to bed soon.
we need the exact contents of the files and the exact command that is crashing
Yep copying it over now
Thought I had it reproducible but forgot about build.zig that is my bad
For the future, the best reproducer is zig build-obj file.zig where file.zig contains the fewest extern functions or comptime blocks that reproduce the issue, this cuts out a lot of possible interference from bugs compiling the startup code
Just tried it on the file that is causing issues, seems to work. Only coredumps on zig test src/once.zig. Gonna copy paste it for now as is. Will help y'all in the morning
The trick if you need a function with argument and return types that aren't compatible with extern is fn entry() void {} comptime { _ = &entry; }