www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9124] New: Object variable of variadic template struct needs explicit "this" in certain situations

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9124

           Summary: Object variable of variadic template struct needs
                    explicit "this" in certain situations
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: puneet coverify.org



---
Kindly look at the code pasted below. with the current github dmd snapshot, it
gives me an error:
Error: this for _val needs to be type Foo not type Foo!(28)

It is a corner case. I could not reduce the code further than give below. For
example if I replace SIZE with N[0] directly in the declarative for result, the
issue disappears.

struct Foo (N...)
{
  enum SIZE = N[0];
  private int _val;

  public void opAssign (T) (T other)
    if (is(T unused == Foo!(_N), _N...))
      {
    _val = other._val;       // compile error
    // this._val = other._val; // explicit this make it work
      }

  public auto opUnary (string op) () if (op == "~") {
    Foo!(SIZE) result = this;
    return result;
  }
}

void main()
{
  Foo!(28) a;
  Foo!(28) b = ~a;
}


Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f6b421121ff945c08bca5bafd8df07913d64a727
fix Issue 9124 - Object variable of variadic template struct needs explicit
"this" in certain situations

https://github.com/D-Programming-Language/dmd/commit/8e22c48774d4200c80e5808f5c0658d28a0625fc


Issue 9124 - Object variable of variadic template struct needs explicit "this"
in certain situations

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 11 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9124


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



https://github.com/D-Programming-Language/dmd/pull/1366

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9124


Puneet Goel <puneet coverify.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |



---
I am reopening the bug with a different testcase that is still failing with the
same error. Please see the comments below in the code to locate the offending
line.

template Foo (T, U, string OP) {
  enum N = T.SIZE;
  alias Foo!(false, true, N) Foo;
}

struct Foo (bool S, bool L, N...) {
  enum SIZE = 5;
  long[1] _a = 0;
  void someFunction() const {
    auto data = _a;        // Does not compile
    // auto data = this._a; // <--- Compiles
  }
  auto opBinary (string op, T) (T ) {
    Foo!(typeof(this), T, op) test;
  }
}

void main() {
  auto p = Foo!(false, false, 5)();
  auto q = Foo!(false, false, 5)();
  p|q;
  p&q;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9124




Thanks for finding another case. My first fix was not sufficient.

https://github.com/D-Programming-Language/dmd/pull/1368

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9124




---

 
 https://github.com/D-Programming-Language/dmd/pull/1368
This looks good. I have taken out all the 132 "this" disambiguators that I had put in my code. The code compiles and runs perfectly now. Thanks Kenji. You Rock! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9124




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/69307c29749ee45ded4c59e58ff01d94b1fbc7bd
2nd fix for Issue 9124 - Object variable of variadic template struct needs
explicit "this" in certain situations

https://github.com/D-Programming-Language/dmd/commit/3662698e1d592693d7556741bc6bf95474908e9a


Issue 9124 & 9143 - manifest constant should be de-symbolize in template
argument comparison

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 17 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9124


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 17 2012