June 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4539



--- Comment #10 from Kenji Hara <k.hara.pg@gmail.com> 2011-06-04 23:19:38 PDT ---
I think the main problem is that dmd treats string literal as lvalue. Lvalue can appear on left hand side of assignment, so string literal now asignable.

Patch comment #7 fixes this behavior, and this change also refuse string literal on ref parameter as a side effect.

It seems to me that it is correct refusing string literal on ref parameter. So this change breaks existing code.

(If D specification treats string literal specially, my think is mistaken.
But it might be not.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4539


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com
           Platform|x86                         |All
         OS/Version|Windows                     |All


--- Comment #11 from yebblies <yebblies@gmail.com> 2011-07-01 23:36:13 EST ---
A new patch that reapplies the old one and fixes the failing tests: https://github.com/D-Programming-Language/dmd/pull/188

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4539



--- Comment #12 from yebblies <yebblies@gmail.com> 2011-09-05 16:30:28 EST ---
The current patch for this issue is https://github.com/D-Programming-Language/dmd/issues/164

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 13, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4539


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jens.k.mueller@gmx.de


--- Comment #13 from yebblies <yebblies@gmail.com> 2011-12-13 16:35:53 EST ---
*** Issue 6882 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: -------
December 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4539


Denis <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg@gmail.com


--- Comment #14 from Denis <verylonglogin.reg@gmail.com> 2011-12-25 13:49:33 MSK ---
*** Issue 7161 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: -------
December 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4539



--- Comment #15 from Kenji Hara <k.hara.pg@gmail.com> 2011-12-25 07:29:50 PST ---
Updated patch. https://github.com/D-Programming-Language/dmd/pull/164

A string literal should be able to bind a reference to static array type.
In the context of ref binding, string literal should work as like static array
value.

Example:

void main()
{
    void foo1(ref string s){}         // ref slice
    void foo2(ref const char[10] s){} // difference of length
    void foo3(ref char[5] s){}        // mutable element

    void foo4(ref const char[5] s)
    {
        assert(s[0] == 'h');
        assert(s[4] == 'o');
    }
    void foo5(ref const ubyte[5] s)
    {
        assert(s[0] == 0xc3);
        assert(s[4] == 0x61);
    }

    static assert(!__traits(compiles, foo1("hello")));
    static assert(!__traits(compiles, foo2("hello")));
    static assert(!__traits(compiles, foo3("hello")));
    foo4("hello");
    foo5(cast(ubyte[5])x"c3fcd3d761");

    import std.conv;
    static assert(!__traits(compiles, parse!int("10") == 10));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4539



--- Comment #16 from github-bugzilla@puremagic.com 2012-01-29 12:21:34 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7f33ed71d8897ec0d03828c41063213af0283d02 Merge pull request #164 from 9rnsr/fix4539

Retry to fix issue 4539 - Refuse assignment to string literal

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4539


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: -------
January 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4539



--- Comment #17 from bearophile_hugs@eml.cc 2012-01-29 14:36:02 PST ---
With the latest DMD2.058head this code:


void foo(immutable ref string) {}
void main() {
    foo("hello");
}


Gives:

test.d(3): Error: function test.foo (ref immutable(char[]) _param_0) is not
callable using argument types (string)

Is this expected?

(Also note the function signature is (ref immutable(char[]) _param_0) while I
have specified an immutable ref).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 29, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4539



--- Comment #18 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-29 15:20:53 PST ---
(In reply to comment #17)
> With the latest DMD2.058head this code:
> 
> 
> void foo(immutable ref string) {}
> void main() {
>     foo("hello");
> }
> 
> 
> Gives:
> 
> test.d(3): Error: function test.foo (ref immutable(char[]) _param_0) is not
> callable using argument types (string)
> 
> Is this expected?
> 
> (Also note the function signature is (ref immutable(char[]) _param_0) while I
> have specified an immutable ref).

Yes, it is expected behavior.
'ref' storage class requires lvalue slice in this case, but string literal
DOESN'T have slice, because it has only content.

Instead, you can get a reference to string literal by `ref immutable(char[5])`
or `ref const(char[5])` (5 == "hello".length), they bind just only content.

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