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

wrong error message when comparing pointers near address-of operator #1737

Closed
daurnimator opened this issue Nov 17, 2018 · 1 comment
Closed

Comments

@daurnimator
Copy link
Collaborator

daurnimator commented Nov 17, 2018

const std = @import("std");

const Foo = struct {
    const Self = @This();

    pub const Bar = struct {
        pub fn init() Bar {
            return Bar {
                .pending = null,
            };
        }

        pending: ?*BarList,
    };

    const BarList = std.LinkedList(Bar);
    expiredList: BarList,

    pub fn init() Self {
        return Self{
            .expiredList = BarList.init(),
        };
    }

    pub fn del(self: *Self, to: *Bar) void {
        if (to.pending) |to_pending| {
            if ((to_pending != &self.expiredList) && (to_pending.first == null)) {
            }
        }
    }
};

test "simple test" {
    var t = Foo.init();
    t.del(&Foo.Bar.init());
}

Fails with:

test.zig:27:51: error: incompatible types: 'bool' and '*bool'
            if ((to_pending != &self.expiredList) && (to_pending.first == null)) {
                                                  ^
test.zig:27:29: note: type 'bool' here
            if ((to_pending != &self.expiredList) && (to_pending.first == null)) {
                            ^
test.zig:27:72: note: type '*bool' here
            if ((to_pending != &self.expiredList) && (to_pending.first == null)) {
                                                                       ^
@daurnimator
Copy link
Collaborator Author

doh. && isn't an operator in zig.

That probably deserves a compiler warning...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant