www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13187] New: Function wrongly deduced as pure

https://issues.dlang.org/show_bug.cgi?id=13187

          Issue ID: 13187
           Summary: Function wrongly deduced as pure
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: schuetzm gmx.net

This compiles:

    int function(int) pure my_func_ptr;

    struct WronglyPure {
        static opDispatch(string fn, Args...)(Args args) {
            return mixin(fn)(args);
        }
    }

    int test() pure {
        return WronglyPure.my_func_ptr(1);
    }

Evidently, `opDispatch` is deduced as pure, but it shouldn't be, because it
access the global variable `my_func_ptr`.

--
Jul 22 2014