zig icon indicating copy to clipboard operation
zig copied to clipboard

method call with optional struct reports compile error

Open andrewrk opened this issue 3 years ago • 0 comments

Zig Version

0.11.0-dev.3+0bbb00035

Steps to Reproduce and Observed Behavior

const S = struct {
    x: i32 = 1234,

    fn method(s: ?S) void {
        _ = s;
    }
};

test {
    var s: S = .{};
    s.method();
}
$ stage3/bin/zig test test.zig 
test.zig:11:6: error: no field or member function named 'method' in 'test.S'
    s.method();
    ~^~~~~~~
test.zig:1:11: note: struct declared here
const S = struct {
          ^~~~~~

Expected Behavior

Test passed, like it does with -fstage1.

andrewrk avatar Nov 02 '22 18:11 andrewrk