Bug 4678 – Built struct is callable without opCall

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-08-19T06:19:00Z
Last change time
2012-05-30T19:39:34Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2010-08-19T06:19:14Z
This D1 program compiles and runs with DMD 2.048: import std.c.stdio: puts; struct Foo { this(int) { puts("THIS"); } } void main() { auto bar = Foo(10); bar(20); } The output: THIS THIS So the Foo constructor is run two times. I think this is not correct. Foo lacks an opCall, so what I expect is a compile-time error that says that 'bar' is not callable.
Comment #1 by bearophile_hugs — 2011-06-26T01:00:13Z
I think there is a pull request with a patch for this bug, do you know what one?
Comment #2 by k.hara.pg — 2012-05-30T19:39:34Z
*** This issue has been marked as a duplicate of issue 6036 ***