www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4803] New: std.range.chain with const string arguments

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

           Summary: std.range.chain with const string arguments
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



A problem found by Pelle Mansson:


import std.range: chain;
void main() {
  const string s = "hello";
  auto r = chain(s, s);
}


Compiled with dmd 2.048:

...\dmd\src\phobos\std\range.d(1162): Error: can only initialize const member
_field_field_0 inside constructor
...\dmd\src\phobos\std\range.d(1162): Error: can only initialize const member
_field_field_1 inside constructor


I think a chain() has to work with const strings too (the items need to be
const if one of the iterables given to chain has const items).

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



10:29:52 PDT ---
What exactly is the purpose of a constant string type?

That type evaluates to const(immutable(char)[]), which wouldn't make much sense
to me.

Note that this will work:

import std.range: chain;
void main() {
    const (char)[] s = "hello";
    auto r = chain(s, s);
}

But I'm not sure if that's what you were after.

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




10:35:43 PDT ---

 What exactly is the purpose of a constant string type?
 
 That type evaluates to const(immutable(char)[]), which wouldn't make much sense
 to me.
 
 Note that this will work:
 
 import std.range: chain;
 void main() {
     const (char)[] s = "hello";
     auto r = chain(s, s);
 }
 
 But I'm not sure if that's what you were after.
Woops, my bad. A string is still appendable, and a const one would not be. I think I understand now. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 03 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4803


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


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


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com



PDT ---
Compiles on 2.059

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

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



15:39:19 PDT ---

 Compiles on 2.059
Thanks for testing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 21 2012