-- struct S(T) 4 { 5 import std.range; 6 7 T[] data; 8 9 auto sortedRange() { return assumeSorted(data); } 10 alias sortedRange this; 11 12 } 13 unittest 14 { 15 auto a1 = S!int([1, 3,3,3, 4, 4]); 16 foreach(i, e; a1) 17 { 18 19 } 20 } -- $ dmd -unittest -main test.d zsh: segmentation fault (core dumped) dmd -unittest -main test.d Both in 2.064 and ~master.
Reduced test case: ------ struct S(T) { import std.range; } unittest { auto a1 = S!int(); foreach(i, e; a1) { } } ------ Seems this has nothing to do with sortedRange, it's a compiler bug.
OK, managed to cut it down to an almost bare-minimal test case: ----range.d---- @property front()() { } --------------- ----test.d---- struct S { import range; } unittest { S a1; foreach(i, e; a1) { } } --------------- Compiler command: dmd -main -unittest test.d
All examples produce an error message since 2.071