www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1570] New: Wrong return for address operator

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

           Summary: Wrong return for address operator
           Product: D
           Version: 2.005
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: PetSerAl gmail.com


import std.stdio;

void main()
{ 
        b v=new b;
        v.f;
        v.a.f;
        (&v.f)();
        (&v.a.f)();
} 

class a
{
        void f()
        {
                writeln("class a");
        }
}

class b:a
{
        void f()
        {
                writeln("class b");
        }
}


This program write:
class b
class a
class b
class b


-- 
Oct 11 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com





What is v.a and where's it documented?  Should it work?


-- 
Nov 08 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, wrong-code





Since I can't at the moment find any evidence in the spec that v.a is a valid
expression, I'm marking this as accepts-invalid.  If I'm wrong, please show me
where it's defined.


-- 
Sep 09 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570







 Since I can't at the moment find any evidence in the spec that v.a is a valid
 expression, I'm marking this as accepts-invalid.  If I'm wrong, please show me
 where it's defined.
 
a is the class a, which for some reason is accessible through a reference to class b. If you capitalize the class names it makes it a lot clearer. I think it might actually be somehow related to the thing about typeof(this) and non-virtual calls made on the expressions page: http://www.digitalmars.com/d/1.0/expression.html In any case it doesn't seem to be explicitly documented, but I wonder if there's a use for it. It breaks encapsulation by allowing you to manually access a base class's implementation of a method, and with single inheritance there's no need to select the implementation from several base classes. --
Sep 09 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com




 It seems to me that sample code is valid.
 Because dmd frontend has v.a as DotTypeExp explicitly and keeps its
 information,
a is not a member of v. So the expression is invalid. Unless you can find something in the spec that states otherwise.
 then resolve overloads of f as A.f.
 Therefore v.a.f should call A.f is right (but not documented) behavior.
 -> Remove 'accepts-invalid' from keywords.
How can a case of the compiler accepting something that the spec doesn't allow be neither accepts-invalid nor a spec issue? 12:45:57 PDT --- v.a is supposed to work, and it means look up the name in the scope of the base class a. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 28 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570





 v.a is supposed to work, and it means look up the name in the scope of the base
 class a.
Nice try. Now supply a link to the relevant bit of the spec. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 28 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570




13:28:55 PDT ---


 v.a is supposed to work, and it means look up the name in the scope of the base
 class a.
Nice try. Now supply a link to the relevant bit of the spec.
If it's not in the spec, it needs to be. Wanna do a pull request? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 28 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570




14:15:21 PDT ---
Fix for compiler, not spec yet:

https://github.com/D-Programming-Language/dmd/commit/2d8f2c76d514e56ccef0f8e77e844f0093c7c4ff

https://github.com/D-Programming-Language/dmd/commit/2c491bcd6bdf482a212b8ef28bb73cdfa6b60155

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 28 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1570




Commit pushed to
https://github.com/D-Programming-Language/d-programming-language.org

https://github.com/D-Programming-Language/d-programming-language.org/commit/9d331033cfa109d8b44e687803cbbbbfc4f4bfe2
fix Issue 1570 - Wrong return for address operator

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


Walter Bright <bugzilla digitalmars.com> changed:

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


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