Bug 4908 – Compile-time use of empty() in Tuple failed depending on order of compilation

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-09-21T12:25:00Z
Last change time
2015-11-01T01:50:03Z
Keywords
rejects-valid
Assigned to
nobody
Creator
rsinfu

Comments

Comment #0 by rsinfu — 2010-09-21T12:25:25Z
I have no reduced test case yet. Unzip the dmd 2.049 release. Add the following lines to std/typecons.d: -------------------- struct Tuple(T...) { + static string test() + { + enum s = ""; + return s.empty ? ";" : ";"; // (316) + } + mixin(test()); // (318) public: -------------------- Then, compiling certain modules fails depending on the order of compilation: -------------------- % dmd -c std/string std/concurrency std/typecons.d(316): Error: cannot evaluate empty("") at compile time std/typecons.d(318): Error: cannot evaluate test() at compile time std/typecons.d(318): Error: argument to mixin must be a string, not (test()) % dmd -c std/concurrency std/string % _ -------------------- The error didn't occur if I modified std.string.indexOf() as follows: -------------------- sizediff_t indexOf(Char1, Char2)(in Char1[] s, in Char2[] sub, CaseSensitive cs = CaseSensitive.yes) { if (cs == CaseSensitive.yes) { static if (Char1.sizeof == Char2.sizeof) { - immutable result = s.length - std.algorithm.find(s, sub).length; + immutable result = 0; return result == s.length ? -1 : result; -------------------- This bug is no longer triggered in phobos since changeset 2032. http://svn.dsource.org/projects/phobos/trunk@2032
Comment #1 by lt.infiltrator — 2015-11-01T01:50:03Z
Since the bug is no longer triggered since an old SVN commit, I think that we can consider this resolved.