D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6069 - DMD tries to call static Foo.opCall() on cast(immutable(Foo))
Summary: DMD tries to call static Foo.opCall() on cast(immutable(Foo))
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-05-28 13:28 UTC by David Nadlinger
Modified: 2012-04-24 04:19 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 David Nadlinger 2011-05-28 13:28:17 UTC
struct Foo {
  static Foo opCall() {
    return Foo.init;
  }
}

void main() {
  auto foo = cast(immutable(Foo)) Foo.init;
}

// test.d(8): Error: function test.Foo.opCall () is not callable using argument types (Foo)
// test.d(8): Error: expected 0 arguments, not 1 for non-variadic function type Foo()

---

I don't know how DMD could possibly try to call a function inside the cast() type parameter, but it seems like it does. const() instead of immutable() produces the error as well, just cast(Foo) works.
Comment 1 David Nadlinger 2011-05-28 13:33:02 UTC
Oh, forgot to add: I'm using latest Git master (2c1a453).
Comment 2 SomeDude 2012-04-23 15:14:49 UTC
Compiles fine on 2.059 Win32
Comment 3 David Nadlinger 2012-04-24 04:19:46 UTC
Can't reproduce it with latest DMD anymore either, closing.