www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15936] New: misleading error message about disable where


          Issue ID: 15936
           Summary: misleading error message about  disable where there is
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ag0aep6g gmail.com

Found by denizzzka who posted to D.learn:
http://forum.dlang.org/post/qbrfftrhiiaotcormyee forum.dlang.org

struct Vector
    void opAssign(Vector u) {}

struct RAMNode
    Vector min;
    const bool isLeafNode = false;

void main()
    RAMNode old_root;
    old_root = RAMNode.init; /* line 15 */

This code can't compile because isLeafNode is const.

dmd gets confused by the opAssign, though, and prints: "test.d(15): Error:
function test.RAMNode.opAssign is not callable because it is annotated with
 disable". That's nonsense. There is no  disable anywhere.

Without the opAssign the error message is ok: "test.d(15): Error: cannot modify
struct old_root RAMNode with immutable members".

Apr 17 2016