[Issue 8709] toLower on alias this

2013-11-09 Thread d-bugmail
https://d.puremagic.com/issues/show_bug.cgi?id=8709


Denis Shelomovskij  changed:

   What|Removed |Added

   Keywords||rejects-valid
 Status|NEW |RESOLVED
 CC||verylonglogin@gmail.com
  Component|DMD |Phobos
 Resolution||WORKSFORME


--- Comment #5 from Denis Shelomovskij  2013-11-09 
12:52:12 MSK ---
(In reply to comment #1)
> Reduced test case:

It is not a reduced testcase. See below.

> struct S
> {
> alias value this;
> string value;
> }
> 
> void main ()
> {
>   auto s = S("hello");
>   char[] arr = "world".dup;
>   s = cast(S)"other";
>   s = cast(S)arr;
> }
> 
> The cast from string to S works, but the cast from char[] to S does not, in
> spite of the fact that their only difference is constness.

`alias this` has nothing to do with casting to type and it is just rewritten to
`S(...)` and  as `char[]` isn't implicitly convertible to `string` it fails. So
the behavior is correct. 

> However, the fact that this came up with std.string.toLower just highlights 
> how
> error-prone it is to use alias this with templated functions. It's insanely
> easy to have template constraints which pass just fine due to the presense of
> alias this but then fail to actually compile or which behave bizarrely due to
> when conversions do and don't happen. I don't know what the solution to that 
> is
> though.

Agree.

So the issue is Phobos one, not dmd one. And `toLower` works now.

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


[Issue 8709] toLower on alias this

2012-10-04 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8709



--- Comment #4 from github-bugzi...@puremagic.com 2012-10-04 13:15:44 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/08722ad38a6f38eeade54a55102153b9765f13c1
Revert "fix issue 8709, from documentation"

This reverts commit d028ef99edd51684f99749d9a2172f95b992c955.

This is causing the build to fail and needs to be fixed before being
merged in again.

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


[Issue 8709] toLower on alias this

2012-10-04 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8709


monarchdo...@gmail.com changed:

   What|Removed |Added

 CC||monarchdo...@gmail.com


--- Comment #3 from monarchdo...@gmail.com 2012-10-04 12:51:09 PDT ---
(In reply to comment #2)
> Commits pushed to master at https://github.com/D-Programming-Language/phobos
> 
> https://github.com/D-Programming-Language/phobos/commit/d028ef99edd51684f99749d9a2172f95b992c955
> fix issue 8709, from documentation
> 
> https://github.com/D-Programming-Language/phobos/commit/bbdbfc7bc0aad1d744b709188e71add3aa27f94a
> Merge pull request #823 from monarchdodra/toAA
> 
> fix issue 8709, from documentation

Typo in fix number, The above has NOTHING to do with this. Sorry.

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


[Issue 8709] toLower on alias this

2012-10-04 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8709



--- Comment #2 from github-bugzi...@puremagic.com 2012-10-04 11:55:10 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/d028ef99edd51684f99749d9a2172f95b992c955
fix issue 8709, from documentation

https://github.com/D-Programming-Language/phobos/commit/bbdbfc7bc0aad1d744b709188e71add3aa27f94a
Merge pull request #823 from monarchdodra/toAA

fix issue 8709, from documentation

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


[Issue 8709] toLower on alias this

2012-09-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=8709


Jonathan M Davis  changed:

   What|Removed |Added

 CC||jmdavisp...@gmx.com
  Component|Phobos  |DMD


--- Comment #1 from Jonathan M Davis  2012-09-23 03:40:50 
PDT ---
Reduced test case:

struct S
{
alias value this;
string value;
}

void main ()
{
  auto s = S("hello");
  char[] arr = "world".dup;
  s = cast(S)"other";
  s = cast(S)arr;
}

The cast from string to S works, but the cast from char[] to S does not, in
spite of the fact that their only difference is constness.

However, the fact that this came up with std.string.toLower just highlights how
error-prone it is to use alias this with templated functions. It's insanely
easy to have template constraints which pass just fine due to the presense of
alias this but then fail to actually compile or which behave bizarrely due to
when conversions do and don't happen. I don't know what the solution to that is
though.

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