On Sat, 04 Feb 2012 15:04:50 +0100, Vidar Wahlberg <[email protected]> wrote:

This code does not compile:
Bar.d:6: Error: function expected before (), not module Struct of type void Bar.d:6: Error: constructor Foo.Foo.this (Struct s) is not callable using argument types (_error_)

Why is that?

I see. There's a hint in the error message: "function expected [...],
not module". Struct is the name of a module, so the compiler thinks
you want to access something inside it. If you want 'Struct' to refer
to the type, you must use selective import[1]:

import Struct : Struct;

This says 'I want only the type Struct from the module Struct, not
everything else in there.'

The other solution is to simply use different names for the type and
the module.


It is. The problem is that bool opEquals(ref const Point) expects a Point by reference, and the return value from your property is a temporary, from
which we can get no reference. The solution is to remove the ref:
bool opEquals(const Point). The only reason to use ref here is to cut down
on copying, and might be worthwhile on larger structures.

I've tried removing the "ref", but I get other errors in return then:
Point.d:19: Error: function Point.Point.opEquals type signature should be const bool(ref const(Point)) not const bool(const const(Point) p) Coordinate.d:20: Error: function Coordinate.Coordinate.opEquals type signature should be const bool(ref const(Coordinate)) not const bool(const const(Coordinate) c)

I cannot seem to recreate this error message. Which version of the
compiler are you using?

[1]: http://www.d-programming-language.org/module.html#ImportDeclaration

Reply via email to