www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4773] New: ]Rebindable should be castable to bool

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

           Summary: ]Rebindable should be castable to bool
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: simen.kjaras gmail.com



PDT ---


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 31 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4773


Simen Kjaeraas <simen.kjaras gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|]Rebindable should be       |[PATCH] Rebindable should
                   |castable to bool            |be castable to bool



PDT ---
Yeah, that's what you get when you press the wrong buttons. :p

Anyways, Rebindable should be castable to bool, to allow for the idiom
Rebindable!T foo; if (foo) {}.

Addition to typecons.d, line 747:

            T opCast(T : bool)()
            {
                return original !is null;
            }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 31 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4773


Shin Fujishiro <rsinfu gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |rsinfu gmail.com
         AssignedTo|nobody puremagic.com        |rsinfu gmail.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4773


Shin Fujishiro <rsinfu gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
         Depends on|                            |5020



---
Actually, it's explicitly castable to bool:

Rebindable!(const Object) r;
if (cast(bool) r) assert(0);
r = new Object;
if (!cast(bool) r) assert(0);

But dmd doesn't forward implicit boolean conversions in if (or other)
conditions to Rebindable's alias-this object.  Reported: bug 5020.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4773


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k.hara.pg gmail.com
          Component|Phobos                      |DMD
           Platform|Other                       |All
         AssignedTo|rsinfu gmail.com            |nobody puremagic.com
            Summary|[PATCH] Rebindable should   |Rebindable should be
                   |be castable to bool         |castable to bool
         OS/Version|Windows                     |All
           Severity|enhancement                 |normal



This is dmd issue.
Fixing bug5020 is incomplete, so property function + alias this is not
implicitly convertible to bool.

----
struct Rebindable
{
    Object obj;
     property const(Object) get(){ return obj; }
    alias get this;
}

Rebindable r;
if (r) assert(0);
r.obj = new Object;
if (!r) assert(0);
----

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



Posted pull request:

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

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


Walter Bright <bugzilla digitalmars.com> changed:

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



10:37:44 PDT ---
https://github.com/D-Programming-Language/dmd/commit/f70793ba34e4c4365eda7a33e3c073a7b13002a6

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


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



*** Issue 5256 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 30 2011