Type Inference in @safe unittests
    jmh530 via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Tue Aug 22 14:44:47 PDT 2017
    
    
  
On Tuesday, 22 August 2017 at 18:25:31 UTC, Steven Schveighoffer 
wrote:
>> 
>> @safe void main()
>> {
>>      struct Foo {
>>          int foo(int i, string s) @safe { return 0; }
>>          double foo2(string s) @safe { return 0; }
>>      }
>>      printMemberTypes!(Foo);
>> }
>
> The surprising part to me is that non- at safe main doesn't infer 
> anything. Is that true?
>
> -Steve
They aren't auto functions or templates, just normal member 
functions of a struct in main. I thought inferring function 
attributes was only for auto functions and templates. I never 
thought it would for member functions of structs in main. But 
yeah, I'm pretty those functions are @safe and not @safe @nogc 
nothrow pure.
    
    
More information about the Digitalmars-d-learn
mailing list