www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1680] New: static struct constructor overloaded with method prevents compilation in inner function

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

           Summary: static struct constructor overloaded with method
                    prevents compilation in inner function
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: schveiguy yahoo.com


Not sure if this is the minimal case.  Also happens on d 1.023

struct X
{
  int _y;
  int blah()
  {
    return _y;
  }

  static X blah(int n)
  {
    return X(n);
  }

  static X blah2(int n)
  {
    return X(n);
  }

  static X blah2(char[] n)
  {
    return X(n.length);
  }
}

void main()
{
  // OK
  X v = X.blah(5);
  void f()
  {
    // OK
    X v1 = X.blah2(5);
    X v2 = X.blah2("hello".dup);

    // Error: 'this' is only allowed in non-static member functions, not f
    X v3 = X.blah(5);
  }
}


-- 
Nov 20 2007