Bug 11489 – Improper implicit cast to immutable.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-09T12:23:00Z
Last change time
2013-11-12T21:04:53Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
shammah.chancellor

Comments

Comment #0 by shammah.chancellor — 2013-11-09T12:23:37Z
import std.stdio; class Hmm { int Hmmor; } class A { Hmm bar; } class Foo : A { this( Hmm _bar) pure { bar = _bar; } } void sendA(immutable A input) { } void sendFoo(immutable Foo input) { } void main() { auto wat = new Hmm(); sendA( new Foo(wat)); }
Comment #1 by andrej.mitrovich — 2013-11-09T13:27:13Z
Comment #2 by shammah.chancellor — 2013-11-09T20:34:29Z
In this case it's a bug, because I have a non-unique non-immutable pointer to Bar still in main(). I removed it by accident, but sendFoo( new Foo() ); is still an error.
Comment #3 by k.hara.pg — 2013-11-12T06:17:20Z
Interestingly it is not related to unique object construction. Reduced test case: class A {} class Foo : A {} void main() { immutable A a = new Foo(); } Compiler fix: https://github.com/D-Programming-Language/dmd/pull/2749
Comment #4 by github-bugzilla — 2013-11-12T19:43:23Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c08bf5ac3de0c51bb51995f937309b6bd4585e1d fix Issue 11489 - Improper implicit cast to immutable. https://github.com/D-Programming-Language/dmd/commit/f7d419a06901923d47bc0cf9b19d22bbb2d3ef2f Merge pull request #2749 from 9rnsr/fix11489 Issue 11489 - Improper implicit cast to immutable.
Comment #5 by github-bugzilla — 2013-11-12T21:04:53Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/8cf0263f036e35b821fabd893dde036cf271feb9 fix Issue 11489, add cast from const(LocalTime) to immutable https://github.com/D-Programming-Language/phobos/commit/f842dac701fcd364e2f2ae9ec1141ba5a9a894cc Merge pull request #1689 from 9rnsr/fix11489 fix Issue 11489, add cast from const(LocalTime) to immutable