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.
Comment #1 by k.hara.pg — 2016-04-27T23:35:20Z
Comment #2 by github-bugzilla — 2016-04-28T08:14:41Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/59b8791d2da7d8e764a1a4dbbab5643cfe746212 fix Issue 15963 - Hidden unresolved forward reference issue in std.uni Add explicit return type to two auto functions `Grapheme.opSlice`, then their calls will have no dependency to return type inference. https://github.com/dlang/phobos/commit/21759179f7c59d20b200ed4dcd751e6afd8b3900 Merge pull request #4253 from 9rnsr/fix15963 Issue 15963 - Hidden unresolved forward reference issue in std.uni