Thread overview
opApply + const
Jan 23
ryuukk_
Jan 23
ryuukk_
Jan 23
ryuukk_
January 23

Hello,

I have the following:


struct Stuff {
    int opApply(scope int delegate(Stuff*) dg)
    {
        return 0;
    }

};
void main()
{
    Stuff* stuff;
    foreach(it; *stuff)
    {}
}

It works fine.. but when the variable becomes const(Stuff)* stuff;

It gives me:

onlineapp.d(13): Error: cannot uniquely infer `foreach` argument types

I have no idea what i should be doing, does anyone have a clue?

January 23

On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote:

>

Hello,

I have the following:


struct Stuff {
    int opApply(scope int delegate(Stuff*) dg)
    {
        return 0;
    }

};
void main()
{
    Stuff* stuff;
    foreach(it; *stuff)
    {}
}

It works fine.. but when the variable becomes const(Stuff)* stuff;

It gives me:

onlineapp.d(13): Error: cannot uniquely infer `foreach` argument types

I have no idea what i should be doing, does anyone have a clue?

Try making opApply const.

January 23

On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote:

>

It works fine.. but when the variable becomes const(Stuff)* stuff;

It gives me:

onlineapp.d(13): Error: cannot uniquely infer `foreach` argument types

I have no idea what i should be doing, does anyone have a clue?

https://issues.dlang.org/show_bug.cgi?id=24353

January 23

On Tuesday, 23 January 2024 at 17:07:18 UTC, Alexandru Ermicioi wrote:

>

On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote:

>

Hello,

I have the following:


struct Stuff {
    int opApply(scope int delegate(Stuff*) dg)
    {
        return 0;
    }

};
void main()
{
    Stuff* stuff;
    foreach(it; *stuff)
    {}
}

It works fine.. but when the variable becomes const(Stuff)* stuff;

It gives me:

onlineapp.d(13): Error: cannot uniquely infer `foreach` argument types

I have no idea what i should be doing, does anyone have a clue?

Try making opApply const.

Thanks that fixed it

January 23

On Tuesday, 23 January 2024 at 17:22:25 UTC, Paul Backus wrote:

>

On Tuesday, 23 January 2024 at 16:11:25 UTC, ryuukk_ wrote:

>

It works fine.. but when the variable becomes const(Stuff)* stuff;

It gives me:

onlineapp.d(13): Error: cannot uniquely infer `foreach` argument types

I have no idea what i should be doing, does anyone have a clue?

https://issues.dlang.org/show_bug.cgi?id=24353

Thanks, the error message was confusing me..

I tried to fix it https://github.com/dlang/dmd/pull/16086