A valid function with no return type?
Meta
jared771 at gmail.com
Fri Sep 25 02:45:16 UTC 2020
On Thursday, 24 September 2020 at 21:39:18 UTC, Stefan Koch wrote:
> On Thursday, 24 September 2020 at 21:32:20 UTC, Meta wrote:
>> On Thursday, 24 September 2020 at 21:26:30 UTC, Max Haughton
>> wrote:
>>> https://issues.dlang.org/show_bug.cgi?id=12638
>>>
>>> https://run.dlang.io/is/jkEIiI
>>>
>>> ref foo() {}
>>>
>>> void main()
>>> {
>>> import std.traits;
>>> pragma(msg, ReturnType!foo);
>>> foo();
>>> }
>>>
>>> Assuming this is supposed to be allowed by the standard,
>>> replacing void with ref (i.e. ref main { ) does not compile
>>> which suggests something isn't right.
>>
>> Anything other than `void main()`, `void main(string[] args)`,
>> `int main()`, `int main(string[] args)` will cause the
>> compiler report a compile error. It's probably special-cased
>> in the compiler somewhere.
>
> Actually that's wrong.
> The compiler will happily accept any number of qualifiers you
> stick on your main.
Qualifiers yes but not return types/storage classes, isn't it?
`ref` here is not a qualifier on the function; it's specifying
the storage class for the return type.
More information about the Digitalmars-d
mailing list