ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.82k stars 2.55k forks source link

previously working code produces message regarding compiler error #10292

Open bradclawsie opened 2 years ago

bradclawsie commented 2 years ago

Zig Version

0.9.0-dev.1910+fffa89700

Steps to Reproduce

this function compiled fine until upgrading to this version of zig:

pub fn randStr() [random_str_len:0]u8 {                                                         
    const random_bytes_count = 24;
    var random_bytes: [random_bytes_count]u8 = undefined;                                       
    std.crypto.random.bytes(&random_bytes);
    var s: [random_str_len:0]u8 = undefined; 
    _ = std.fs.base64_encoder.encode(&s, &random_bytes);                                        
    return s;
}

now, I see (I've inserted some newlines)

broken LLVM module found: Call parameter type does not match function signature!              
%id = alloca [32 x i8], align 1                                                            
[33 x i8]*  call fastcc void @.grokloc_security_crypt.randStr([32 x i8]* sret([33 x i8]) %id), !dbg !2779                                                                              Call parameter type does not match function signature!                                        
%bad_id = alloca [32 x i8], align 1                                                        
[33 x i8]*  call fastcc void @.grokloc_security_crypt.randStr([32 x i8]* sret([33 x i8]) %bad_id), !dbg !2787                                                                          Call parameter type does not match function signature!                                        
%3 = getelementptr inbounds { [32 x i8], i16 }, { [32 x i8], i16 }* %0, i32 0, i32 0, !dbg !3442                                                                                       [33 x i8]*  call fastcc void @randStr([32 x i8]* sret([33 x i8]) %3), !dbg !3442                                                                                                                                                                           This is a bug in the Zig compiler.thread 1240 panic:                                        
Unable to dump stack trace: debug info stripped

Expected Behavior

compile like before

Actual Behavior

message about a compiler bug

bradclawsie commented 2 years ago

just a quick clarification here...upon review, my code did indeed have some errors related to type mismatches, and I fixed those

the crux of this issue imho is how zig detects this error and messages the user about it

thanks again, I'm enjoying learning zig

RetroDev256 commented 2 months ago

Is this a duplicate of #9469?