utils.toBulkString is not accesible from utils

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 3 03:51:46 PST 2015


On Wednesday, December 02, 2015 06:33:32 Andre via Digitalmars-d-learn wrote:
> Hi,
>
> for following coding there is an error during compilation:
>
>    module utils;
>
>    package string toBulkString(string s)
>    {
>     import std.string: format;
>     return "$%s\r\n%s\r\n".format(s.length, s);
>    }
>
>    unittest
>    {
>     string actual = "foobar".toBulkString();
>     //...
>    }
>
> >> source\utils.d(11,39): Error: function utils.toBulkString is
> >> not accessible from module utils
>
> The error disappears if I change the visibility attribute from
> package to private.
> This seems to be a bug, is it?
>
> Version: DMD v2.069.0-b2
>
> Kind regards
> André

I believe that the problem is that there is no package for toBulkString to
be in. utils is a top-level module and is not in a package. Now, arguably it
should be an error to use the package attribute in such a module rather than
giving an error when you try and use it, but I'm pretty sure that that's the
source of your problem. If utils were actually in a package, then it should
work.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list