Error: variable foo conflicts with struct foo

Paul Backus snarwin at gmail.com
Thu Jan 4 17:59:18 UTC 2018


On Thursday, 4 January 2018 at 17:45:35 UTC, Stijn wrote:
> Why is it not allowed for a variable name to match a type name? 
> The following example fails with "Error: variable foo conflicts 
> with struct foo"
>
>     struct foo {}
>     foo foo;

Imagine if you then tried to write something like

     alias bar = foo;

Or, imagine you placed the above declarations into the module 
`mymod.d`, and then in a different module wrote

     import mymod: foo;

Which `foo` should these refer to, the type or the variable?


More information about the Digitalmars-d-learn mailing list