Is it intentional that forward references in unittests aren't supported nor detected?
Steven Schveighoffer
schveiguy at yahoo.com
Fri Jun 4 04:56:53 PDT 2010
On Thu, 03 Jun 2010 18:04:26 -0400, Trass3r <un at known.com> wrote:
> void main()
> {
> }
>
> unittest
> {
> struct S
> {
> S2 s;
> }
>
> struct S2
> {
> }
>
> S s;
> }
>
> yields:
> unittests.d(9): Error: identifier 'S2' is not defined
> unittests.d(9): Error: S2 is used as a type
> unittests.d(8): Error: no size for type _error_
> Error: no size for type _error_
>
>
> while putting S2 in front of S works makes it work.
>
> Is this intentional?
unittest is a function. It's basically a single function per module that
is a concatenation of all the unit tests in the module. Inside functions,
forward references are not allowed.
You can declare types or include imports using version(unittest) and then
forward references should work.
-Steve
More information about the Digitalmars-d
mailing list