Bug 3640 – shared this() constructor does not work and reports strange errors without line numbers
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-12-23T17:23:00Z
Last change time
2015-06-09T01:27:05Z
Assigned to
nobody
Creator
jason.james.house
Comments
Comment #0 by jason.james.house — 2009-12-23T17:23:33Z
Sample code:
=================================
class foo{
shared this(){}
}
void main(){
auto x = new shared(foo)();
}
=================================
Result with dmd 2.037
(bug report lists 2.036, but that's because 2.037 was not an option at the time)
$ dmd test.d
Error: cannot implicitly convert expression (this) of type shared(foo) to test.foo
I have no idea what inspired me to originally try this variation of a constructor since dropping the shared keyword results in code that compiles. Moving the shared keyword after the constructor declaration (AKA this() shared{}) results in a parse error.
Comment #1 by yebblies — 2011-06-09T00:30:48Z
This code compiles and runs with no errors on dmd 2.053