[Issue 22792] Wrong inference of opApply
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 20 12:03:07 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22792
--- Comment #2 from moonlightsentinel at disroot.org ---
Slightly modified test case:
import core.stdc.stdio;
struct S
{
int opApply(int delegate(ref const(int), ref int) dg)
{ puts("mutable int"); return 0; }
int opApply(int delegate(ref const(int), ref const(int)) dg) const
{ puts("const int"); return 0; }
int opApply(int delegate(ref const(int), ref string) dg)
{ puts("mutable str"); return 0; }
int opApply(int delegate(ref const(int), ref const(string)) dg) const
{ puts("const str"); return 0; }
}
void main()
{
S s;
foreach (ref const(int) x, ref const(int) y; s) {}
foreach (ref const(int) x, ref const(string) y; s) {}
const S s2;
foreach (ref const(int) x, ref const(int) y; s2) {}
foreach (ref const(int) x, ref const(string) y; s2) {}
}
Up to 2.074.1: Success with output:
-----
const int
const str
const int
const str
-----
Since 2.075.1: Success with output:
-----
const int
mutable str
const int
const str
-----
--
More information about the Digitalmars-d-bugs
mailing list