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

stage1: incompatible types (parameterized structs) not detected in analysis #3224

Closed
mikdusan opened this issue Sep 13, 2019 · 2 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@mikdusan
Copy link
Member

mikdusan commented Sep 13, 2019

looks like a regression and suspect commit: b2d94f9 a5cb0f7

error

Call parameter type does not match function signature!
  %list = alloca %"std.array_list.AlignedArrayList(bool,null)", align 8
 %"std.array_list.AlignedArrayList(u64,null)"*  call fastcc void @"std.array_list.AlignedArrayList(u64,null).init"(%"std.array_list.AlignedArrayList(bool,null)"* sret %list, %std.mem.Allocator* @direct_allocator_state), !dbg !830
LLVM ERROR: Broken module found, compilation aborted!

expected error

error: expected type 'std.array_list.AlignedArrayList(bool,1)', found 'std.array_list.AlignedArrayList(u64,8)'

reduction

const std = @import("std");
  
const List = std.ArrayList(bool);

export fn entry() void {
    var list: List = undefined;
    list = std.ArrayList(u64).init(std.heap.direct_allocator);
}

pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn {
    while (true) {}
}
@andrewrk andrewrk added this to the 0.5.0 milestone Sep 16, 2019
@andrewrk andrewrk added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Sep 16, 2019
@andrewrk
Copy link
Member

andrewrk commented Sep 16, 2019

Further reduction:

fn init() struct {
    y: f64,
} {
    return undefined;
}

export fn entry() void {
    var list: struct {
        x: i32,
    } = undefined;
    list = init();
}

pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn {
    while (true) {}
}

@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 30, 2019
@mikdusan
Copy link
Member Author

mikdusan commented Oct 14, 2019

IR (before a5cb0f7)

Entry_0:
    #1  | (unknown)   | - | ResetResult(none)
    #2  | (unknown)   | - | ResetResult(none)
    #3  | (unknown)   | - | ResetResult(none)
    #4  | type        | 2 | struct:8:15
    #5  | (unknown)   | - | EndExpr(result=none,value=struct:8:15)
    #6  | bool        | 2 | false
    #7  | (unknown)   | 1 | Alloca(align=(null),name=list)
    #8  | (unknown)   | - | ResetResult(var(#7))
    #9  | (unknown)   | - | ResetResult(none)
    #10 | (undefined) | 2 | undefined
    #11 | (unknown)   | - | EndExpr(result=none,value=undefined)
    #12 | (unknown)   | 1 | @implicitCast(struct:8:15,undefined)
    #13 | (unknown)   | - | EndExpr(result=var(#7),value=#12)
    #14 | void        | - | var list = #7 // comptime = false
    #15 | (unknown)   | - | ResetResult(none)
    #16 | (unknown)   | - | ResetResult(none)
    #17 | (unknown)   | 1 | &list
    #18 | (unknown)   | - | ResetResult(none)
    #19 | (unknown)   | - | ResetResult(none)
    #20 | (unknown)   | 2 | declref init
    #21 | (unknown)   | - | EndExpr(result=none,value=#20)
    #22 | (unknown)   | - | #20()result=none
    #23 | (unknown)   | - | EndExpr(result=none,value=#22)
    #24 | void        | - | *#17 = #22
    #25 | void        | 2 | {}
    #26 | (unknown)   | - | EndExpr(result=none,value={})
    #27 | (unknown)   | - | @checkStatementIsVoid({})
    #28 | void        | 0 | {}
    #29 | void        | 3 | {}
    #30 | (unknown)   | - | EndExpr(result=none,value={})
    #31 | (unknown)   | - | @addImplicitReturnType({})
    #32 | noreturn    | - | return {}
}

IR (a5cb0f7)

Entry_0:
    #1  | (unknown)   | - | ResetResult(none)
    #2  | (unknown)   | - | ResetResult(none)
    #3  | (unknown)   | - | ResetResult(none)
    #4  | type        | 2 | struct:8:15
    #5  | (unknown)   | - | EndExpr(result=none,value=struct:8:15)
    #6  | bool        | 2 | false
    #7  | (unknown)   | 1 | Alloca(align=(null),name=list)
    #8  | (unknown)   | - | ResetResult(var(#7))
    #9  | (unknown)   | - | ResetResult(none)
    #10 | (undefined) | 2 | undefined
    #11 | (unknown)   | - | EndExpr(result=none,value=undefined)
    #12 | (unknown)   | 1 | @implicitCast(struct:8:15,undefined)
    #13 | (unknown)   | - | EndExpr(result=var(#7),value=#12)
    #14 | void        | - | var list = #7 // comptime = false
    #15 | (unknown)   | - | ResetResult(none)
    #16 | (unknown)   | - | ResetResult(none)
    #17 | (unknown)   | 1 | &list
    #18 | (unknown)   | - | ResetResult(inst(#17))
    #19 | (unknown)   | - | ResetResult(none)
    #20 | (unknown)   | 2 | declref init
    #21 | (unknown)   | - | EndExpr(result=none,value=#20)
    #22 | (unknown)   | - | #20()result=inst(#17)
    #23 | (unknown)   | - | EndExpr(result=inst(#17),value=#22)
    #24 | void        | 2 | {}
    #25 | (unknown)   | - | EndExpr(result=none,value={})
    #26 | (unknown)   | - | @checkStatementIsVoid({})
    #27 | void        | 0 | {}
    #28 | void        | 3 | {}
    #29 | (unknown)   | - | EndExpr(result=none,value={})
    #30 | (unknown)   | - | @addImplicitReturnType({})
    #31 | noreturn    | - | return {}
}

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

Successfully merging a pull request may close this issue.

2 participants