Error: no property "someFont" for type int

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 10 23:46:29 PST 2015


On Wednesday, 11 November 2015 at 06:37:44 UTC, Marco de Wild 
wrote:

>
> In directory.d:
> using style;

This is not D. It should be giving you a compiler error. How are 
you compiling? Or did you type 'using' in the post by mistake? 
Anyway, what you want is:

import style;

>
> In style.d:
> module style;
> (...)
> public static class Style
> {

'static class' has no meaning in module scope, only for inner 
classes. It's not the cause of your problem though.

>
> I'm getting the error message that the compiler can't find
> source/directory.d(...) : Error: no property 'DirectoryFont' 
> for type 'int'.
> When I change the line to actually contain the (iirc optional) 
> brackets, the type changes to 'Style'. Am I missing something 
> with regards to static classes and members in D?
> Thanks in advance.

The error is likley because of a symbol conflict. Assuming that 
Text is from the module dsfml.text.graphics, it has an enum type 
named Style. There's an unfortunate issue in D that allows both 
of the following to compile:

auto e1 = Text.Style.Regular;
_text.Style.Regular;

The latter should not be allowed, IMO, but it is what it is. So 
in your case, accessing your Style class in the scope of 
with(_text) is causing the compiler to find _text.Style. The 
solution is to use the FQN (Fully Qualified Name) on your Style 
inside the with, i.e. style.Style, or to drop the with altogether.







More information about the Digitalmars-d-learn mailing list