lifetime issue: Bug or not?

Meta jared771 at gmail.com
Sun Nov 24 09:05:14 UTC 2019


On Saturday, 23 November 2019 at 04:20:33 UTC, Steven 
Schveighoffer wrote:
> On 11/22/19 10:46 PM, Meta wrote:
>> 
>> Are you passing the -dip1000 switch to the compiler? I 
>> reproduced this with a toy version of your code, but the 
>> compile error goes away when I pass the -dip1000 switch to the 
>> compiler.
>
> I am not. But I admit that I didn't have the return attribute 
> at first. I added it to see if it helped (it didn't).
>
> Can you post the toy version? Might be reasonable for a bug 
> report. I couldn't figure out a minimal case.
>
> -Steve

It's just your code (@safe added for good measure):

@safe:

struct SQLStatement
{
     string s;
}

struct X
{
    SQLStatement foo(int id)
    {
       auto stmt = SQLStatement("`foo`"); // table
       return stmt.where("`id` = ?", id);
    }
}

ref SQLStatement where(T)(return ref SQLStatement stmt, string 
clause, T val)
{
     return stmt;
}

void main()
{
     X x;
     x.foo(1);
}

This code fails to compile unless dip1000 is turned on.




More information about the Digitalmars-d mailing list