lifetime issue: Bug or not?
Steven Schveighoffer
schveiguy at gmail.com
Sun Nov 24 16:28:18 UTC 2019
On 11/24/19 4:05 AM, Meta wrote:
> 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.
>
>
Oh my, I swear I put something similar into run.dlang.io and it compiled
fine.
I'll file a bug.
-Steve
More information about the Digitalmars-d
mailing list