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

either move callconv to be just after fn keyword, or put comptime arguments in scope of callconv expression #4630

Open
alexnask opened this issue Mar 4, 2020 · 5 comments
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone

Comments

@alexnask
Copy link
Contributor

alexnask commented Mar 4, 2020

Example:

fn foo(comptime flag: bool) callconv(if (flag) .Unspecified else .Async) void {}

test "" {
    // Yields: "error: use of undeclared identifier 'flag'"
    foo(true);
}
@alexnask alexnask changed the title Arguments are not available to callconv expression Comptime arguments are not available to callconv expression Mar 4, 2020
@LemonBoy
Copy link
Contributor

LemonBoy commented Mar 4, 2020

That's intended (I can vouch for the callconv parameter at least), the callconv and align are evaluated in the scope containing the function and independently from its parameters.

@alexnask
Copy link
Contributor Author

alexnask commented Mar 4, 2020

Fair enough, closing this.

@alexnask alexnask closed this as completed Mar 4, 2020
@andrewrk
Copy link
Member

andrewrk commented Mar 4, 2020

Hang on, the whole point of having callconv after the parameters rather than after the fn keyword is so that it would make sense for the comptime parameters to be in scope.

I actually thought they were in scope until just now. So one of two things needs to happen:

  • Decide that comptime args will not be in spec for callconv purposes (status quo), and therefore move callconv to be after the `fn keyword, or
  • Change the callconv expression to have comptime parameters in scope

I propose the latter, to match align.

@andrewrk andrewrk reopened this Mar 4, 2020
@andrewrk andrewrk added this to the 0.7.0 milestone Mar 4, 2020
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Mar 4, 2020
@andrewrk andrewrk changed the title Comptime arguments are not available to callconv expression either move callconv to be just after fn keyword, or put comptime arguments in scope of callconv expression Mar 4, 2020
@ghost
Copy link

ghost commented Mar 5, 2020

#4285

@ghost
Copy link

ghost commented Apr 30, 2020

I'll second #4285. I've worked out a way to make it non-breaking, and it has a whole lot of other benefits as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This proposal is planned. proposal This issue suggests modifications. If it also has the "accepted" label then it is planned.
Projects
None yet
Development

No branches or pull requests

3 participants