[Issue 7707] New: Purity inference fails when template used before it's defined
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 13 21:27:53 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7707
Summary: Purity inference fails when template used before it's
defined
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2012-03-13 21:28:03 PDT ---
2.059 HEAD
If you change std.utf.toUTFz to
const(wchar)* toUTF16z(C)(const(C)[] str) @system
if(isSomeChar!C)
{
return toUTFz!(const(wchar)*)(str);
}
unittest
{
toUTF16z("hello world");
}
then compilation fails with this error:
std/utf.d(1373): Error: pure function 'toUTF16z' cannot call impure function
'toUTFz'
std/utf.d(1378): Error: template instance std.utf.toUTF16z!(char) error
instantiating
make[1]: *** [generated/linux/debug/64/unittest/std/utf] Error 1
make: *** [unittest] Error 2
toUTFz is _not_ marked as pure, and neither is toUTF16z. I don't believe that
toUTFz _can_ be pure (certainly, it _shouldn't_ be given what it does), so it
should always infer as impure, which would cause toUTF16z be inferred as impure
if it's changed to call toUTFz as is done above.
However, if you move toUTF16z to after the definition of toUTFz, then it
compiles. So, it appears to be a forward declaration issue.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list