Skip to content

LLVM error when function returns !?[]u8 as !?[]const u8 #4123

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
ghost opened this issue Jan 9, 2020 · 1 comment
Closed

LLVM error when function returns !?[]u8 as !?[]const u8 #4123

ghost opened this issue Jan 9, 2020 · 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

@ghost
Copy link

ghost commented Jan 9, 2020

fn inner() !?[]u8 {
    return error.Damn;
}

fn outer() !?[]const u8 {
    return inner();
}

pub fn main() void {
    _ = outer() catch {};
}
broken LLVM module found: Call parameter type does not match function signature!
{ %"?[]const u8", i16 }* %0
 { %"?[]u8", i16 }*  call fastcc void @inner({ %"?[]const u8", i16 }* sret %0, %std.builtin.StackTrace* %1), !dbg !1050

This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
Abort trap: 6

It works if both functions return the same type (both const or both non-const).

If it's reversed so that inner returns !?[]const u8 and outer returns !?[]u8, it correctly gives a compile error.

I think my code should compile. It works if I add a redundant try in the return statement.

@daurnimator daurnimator added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Jan 10, 2020
@andrewrk andrewrk added this to the 0.6.0 milestone Jan 17, 2020
@daurnimator
Copy link
Contributor

(error still exists on master)

@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Mar 4, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Aug 13, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 28, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 29, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Dec 29, 2022
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

2 participants