https://issues.dlang.org/show_bug.cgi?id=17871
--- Comment #3 from [email protected] --- (In reply to Mathias Lang from comment #2) > It is rather inconsistent though: > ``` > auto wrapper = (foo) {}; > ``` > Doesn't compile, but: > ``` > auto wrapper = (int) {}; > ``` > Does. The key here is that `int` is a built-in type. I.e., "int" is a keyword and cannot be used as a parameter name. dmd is being smart and recognizes it as the type then. Similarly, stuff like `auto wrapper = (typeof(size_t.init)) {};` works, because `typeof(size_t.init)` isn't an identifier, so it can't be a parameter name. [...] > The grammar mentions that a FunctionLiteral > (https://dlang.org/spec/grammar.html#FunctionLiteral) is, in this case: > ParameterMemberAttributes FunctionLiteralBody > > Skipping a couple of intermediate steps, we end up with a list of Parameter > (https://dlang.org/spec/grammar.html#Parameter) which always starts with > `Type` or `BasicType`, so it looks like the grammar is not up to date in > that regard (unless I'm again missing something?). I think you're right. The compiler treats single identifiers differently in function literals than in function declarations (in `void f(size_t) {}`, "size_t" is the parameter *type*). But the grammar is the same for both. It should probably show the difference. Grammar-wise, the "size_t" in `(size_t) {}` is matched by the rule `Parameter: InOut_opt Type` ("size_t" -> Identifier -> ... -> Parameter). It could be argued that semantic analysis makes a parameter name out of the "Type". But then the grammar is clearly misleading. --
