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

std.sort.block anonymous struct #21244

Closed
StringNick opened this issue Aug 29, 2024 · 1 comment
Closed

std.sort.block anonymous struct #21244

StringNick opened this issue Aug 29, 2024 · 1 comment
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@StringNick
Copy link

Zig Version

0.14.0-dev.1342+1a178d499

Steps to Reproduce and Observed Behavior

Maybe its not a bug and anonymous struct is not allowed to use.

const std = @import("std");

pub fn compare(_: void, lhs: struct {u64}, rhs: struct{u64}) bool {
    return lhs[0] < rhs[0];
}


test "dfd"  {
    var d = std.ArrayList(struct{u64}).init(std.testing.allocator);
    defer d.deinit();
    
    try d.appendSlice(&.{ .{5}, .{1}, .{3}});
    
    std.sort.block(struct{u64}, d.items, {}, compare);
}

returning just failure with status 139 (without any error info)
but if we remove anonymous decl, and add type everything works:

const std = @import("std");

pub fn compare(_: void, lhs: tt, rhs: tt) bool {
    return lhs[0] < rhs[0];
}

const tt = struct {u64};


test "dfd"  {
    var d = std.ArrayList(tt).init(std.testing.allocator);
    defer d.deinit();
    
    try d.appendSlice(&.{ .{5}, .{1}, .{3}});
    
    std.sort.block(tt, d.items, {}, compare);
}

Expected Behavior

Working behavior

@StringNick StringNick added the bug Observed behavior contradicts documented or intended behavior label Aug 29, 2024
@xdBronch
Copy link
Contributor

duplicate of #20759

@Vexu Vexu closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 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
Projects
None yet
Development

No branches or pull requests

3 participants