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

Mutating "methods" can't be called on zero sized struct. #838

Hejsil opened this Issue Mar 17, 2018 · 1 comment


None yet
3 participants

Hejsil commented Mar 17, 2018

const S = struct {
    fn doC(s: &const S) void {}
    fn do(s: &S) void {}

test "" {
    var s = S{};
    S.doC(&s); // works!
    s.doC();   // works!;  // works!;    // error: expected type '&S', found 'S'

@Hejsil Hejsil added the bug label Mar 18, 2018


This comment has been minimized.


Sahnvour commented Mar 21, 2018

The branch between empty and non empty structs happens at where an empty struct "handle" is not considered a pointer since 7bc0145.
We end up with first_arg being S instead of &S.

At this point I'm not sure what the correct fix would be.

@andrewrk andrewrk added this to the 0.3.0 milestone Mar 21, 2018

@andrewrk andrewrk closed this in 2594132 Jun 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment