Bug 15963 – Hidden unresolved forward reference issue in std.uni
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-04-27T23:26:00Z
Last change time
2016-04-28T08:14:42Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2016-04-27T23:26:46Z
Minimized test case from std.uni module code:
void main()//unittest
{
Grapheme()[];
}
struct SliceOverIndexed(T)
{
enum assignableSlice = is(typeof({ T.init[0..0] = Item.init; }));
alias Item = typeof(T.init[0]);
size_t from, to;
T* arr;
}
SliceOverIndexed!T sliceOverIndexed(T)(size_t a, size_t b, T* x)
{
return SliceOverIndexed!T(a, b, x);
}
struct Grapheme
{
dchar opIndex(size_t index) const pure nothrow @nogc
{
return 'a';
}
@system auto opSlice(size_t a, size_t b) pure nothrow @nogc
{
return sliceOverIndexed(a, b, &this);
}
@system auto opSlice() pure nothrow @nogc
{
return sliceOverIndexed(0, 0, &this);
}
}
Two opSlice auto functions in Grapheme depends on a return type of template function sliceOverIndexed. But the instantiated type SliceOverIndexed!Grapheme depends on is(typeof({ Grapheme.opSlice(0, 0) = dchar.init; })). In short, there's an unresolved forward reference issue.
The hiding error is a bug of current dmd, but the Phobos code needs to be fixed first.