[Issue 5006] 'pure' unenforced in a nested function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 31 15:53:50 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5006


Lewis <lewis1711 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lewis1711 at gmail.com
         OS/Version|Windows                     |Linux
           Severity|normal                      |major


--- Comment #4 from Lewis <lewis1711 at gmail.com> 2010-10-31 15:52:50 PDT ---
I can confirm this bug.

It especially annoying because if you copypasta the bit on pure functionns
straight out of TDPL it *will compile*, when the comment says it shouldn't.

import std.stdio;

void main()
{
    pure bool leapYear(uint y)
    {
        auto result = (y % 4) == 0 && (y % 100 || (y % 400) == 0);
        if (result) writeln(y, " is a leap year!"); // Error!
        // Cannot call impure function writeln from pure function!
        return result;
    }

    leapYear(1);
}

-- 
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