[Issue 15963] New: Hidden unresolved forward reference issue in std.uni
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Apr 27 16:26:46 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=15963
Issue ID: 15963
Summary: Hidden unresolved forward reference issue in std.uni
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list