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

error: <function const> depends on itself #1144

Closed
kristate opened this issue Jun 21, 2018 · 3 comments
Closed

error: <function const> depends on itself #1144

kristate opened this issue Jun 21, 2018 · 3 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@kristate
Copy link
Contributor

kristate commented Jun 21, 2018

Could be related to #624 and/or #679

zig version
0.2.0+55193cb1

Test case:

const my_callback_h = fn (*MyStruct) error!void;

const MyStruct = struct {
  callback: my_callback_h,

  fn init(cb: my_callback_h) MyStruct {
    return MyStruct {
      .callback = cb,
    };
  }
};

fn main_callback(ms: *MyStruct) error!void {
  return;
}

pub fn main() void {
  var a = MyStruct.init(main_callback);
}

Returns

main.zig:1:1: error: 'my_callback_h' depends on itself
const my_callback_h = fn (*MyStruct) error!void;
^
@andrewrk andrewrk added this to the 0.3.0 milestone Jun 21, 2018
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Jun 21, 2018
@andrewrk
Copy link
Member

andrewrk commented Jun 21, 2018

Here's a workaround in the meantime:

const my_callback_h = fn (*MyStruct) error!void;

const MyStruct = struct {
    callback: fn (*MyStruct) error!void,

    fn init(cb: fn (*MyStruct) error!void) MyStruct {
        return MyStruct{ .callback = cb };
    }
};

fn main_callback(ms: *MyStruct) error!void {
    return;
}

pub fn main() void {
    var a = MyStruct.init(main_callback);
}

@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Sep 4, 2018
@andrewrk
Copy link
Member

andrewrk commented Mar 1, 2019

I'm pretty sure this is a duplicate of #624 and not #679. I'll leave it open until this test case is covered.

@andrewrk
Copy link
Member

fixed by #2174

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

2 participants