dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Inconsistent grammar parsing function types in parameters vs. other contexts

Open dlangBugzillaToGithub opened this issue 4 years ago • 1 comments

Vladimir Panteleev (@CyberShadow) reported this on 2021-06-20T00:09:38Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=22047

Description

extern(C) pure nothrow @safe @nogc void function() p; // OK
alias extern(C) pure nothrow @safe @nogc void function() a; // OK
alias b = extern(C) pure nothrow @safe @nogc void function() p; // OK
void fun(extern(C) pure nothrow @safe @nogc void function() p); // Error

dlangBugzillaToGithub avatar Jun 20 '21 00:06 dlangBugzillaToGithub

alias b = extern(C) pure nothrow @safe @nogc void function() p; // OK

(Without the p that compiles). alias supports StorageClass, so that works.

void fun(extern(C) pure nothrow @safe @nogc void function() p); // Error

FunctionAttributes come after the parameter list:

void fun(void function() pure nothrow @safe @nogc p); // OK

I removed extern(C), that is not in the FunctionAttribute grammar - that's #18171. I suggest we close this in favour of that one.

ntrel avatar Nov 20 '25 21:11 ntrel