D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6338 - Immutability is lost for shared(immutable(T))
Summary: Immutability is lost for shared(immutable(T))
Status: RESOLVED DUPLICATE of issue 6922
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-17 06:07 UTC by Lars T. Kyllingstad
Modified: 2011-11-10 01:42 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Lars T. Kyllingstad 2011-07-17 06:07:31 UTC
Test cases:

    pragma(msg, (shared(immutable(int))).stringof);
    pragma(msg, (shared(immutable(int[]))).stringof);

Prints:

    shared(int)
    shared(immutable(int)[])

Expected:

    immutable(int)
    immutable(int[])

In the first case, immutability is lost altogether; in the second case, immutability is lost on the outermost type.
Comment 1 Lars T. Kyllingstad 2011-07-17 06:36:18 UTC
Actually, never mind the "expected" comment here.  I don't know what to expect. :)  It is probably better to keep the shared qualifier as well, not collapsing the types at all.
Comment 2 Jerry Quinn 2011-09-16 18:20:22 UTC
I think the collapsing might be required.  I was going to report this separately but it looks like a facet of your bug.

import std.stdio;
synchronized class foo {
  File file;
  this(string infile) {
    file.open(infile);
  }
}


~/dmd2/linux/bin64/dmd -c junk.d
junk.d(5): Error: function std.stdio.File.open (string name, in const(char[]) stdioOpenmode = "rb") is not callable using argument types (string) shared
/home/jlquinn/dmd2/linux/bin64/../../src/phobos/std/stdio.d(292): Error: destructor std.stdio.File.~this () is not callable using argument types ()


The compiler (dmd 2.055) doesn't realize that shared(string) is equivalent to string.
Comment 3 Kenji Hara 2011-11-10 01:42:21 UTC

*** This issue has been marked as a duplicate of issue 6922 ***