Bug 3091 – "auto x = new shared foo" does not compile

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-06-23T20:46:00Z
Last change time
2015-06-09T01:27:56Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
jason.james.house

Attachments

IDFilenameSummaryContent-TypeSize
402main.dFile demonstrating the issuetext/x-dsrc106

Comments

Comment #0 by jason.james.house — 2009-06-23T20:46:21Z
Created attachment 402 File demonstrating the issue Attached is a simple test case that I think should compile. It seems that shared foo must be replaced with shared(foo). It's certainly easier to type in the way I'm hoping for. Things get a bit ridiculous when templates are involved auto x = new shared(foo!(bar, baz))(alpha, beta); Anything that can be done to reduce the parenthesis is nice.
Comment #1 by dfj1esp02 — 2009-10-28T10:02:46Z
Seems like an RFE. Try to compile this: --- class A{} int main() { const a = new const A(); const a = new immutable A(); return 0; } ---
Comment #2 by k.hara.pg — 2011-12-12T04:07:44Z
NewExp and StructLiteralExp have this issue. inout(int) test3091(inout(int) _dummy = 0) { struct Foo {} auto pm = new Foo; auto pc = new const Foo; auto pw = new inout Foo; auto psm = new shared Foo; auto psc = new shared const Foo; auto psw = new shared inout Foo; auto pi = new immutable Foo; auto m = Foo(); auto c = const Foo(); auto w = inout Foo(); auto sm = shared Foo(); auto sc = shared const Foo(); auto sw = shared inout Foo(); auto i = immutable Foo(); return 0; }
Comment #3 by k.hara.pg — 2011-12-12T04:27:19Z
Comment #4 by jason.james.house — 2011-12-12T05:13:23Z
With that patch, when will "new shared foo()" be allowed? Is it semantically equivalent to "cast(shared) new foo()"?
Comment #5 by k.hara.pg — 2011-12-12T05:33:41Z
(In reply to comment #4) > With that patch, when will "new shared foo()" be allowed? Is it semantically > equivalent to "cast(shared) new foo()"? "new shared foo()" is allowed, and it is semantically equivalent to "new shared(foo)()", not cast.
Comment #6 by github-bugzilla — 2012-09-25T01:28:44Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/77a617330302166c334f7760fb02e57032d08d21 Issue 3091 - "auto x = new shared foo" does not compile https://github.com/D-Programming-Language/dmd/commit/ec3e3300949b5aef30c7a71a0287a77135739144 Merge pull request #556 from 9rnsr/fix3091 Issue 3091 & 6873 - Make "StorageClasses Type" syntax available in some where
Comment #7 by k.hara.pg — 2012-09-25T06:44:15Z