www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18097] New: [REG2.077] Unittest function is undefined

https://issues.dlang.org/show_bug.cgi?id=18097

          Issue ID: 18097
           Summary: [REG2.077] Unittest function is undefined identifier
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: johanengelen weka.io

Pre 2.077, this code worked:
```
unittest // first unittest
{
}

unittest // second unittest
{
    auto a = &mixin(__traits(identifier, __traits(parent, {  })));
    auto b = &__traits(parent, {  });

    //auto c = &__unittestL3_2; // dlang 2.076
    //auto c = &__unittest_dummy_d_3_2; //dlang 2.077
}
```

The purpose of the code is to obtain the address of the unittest function.
Either `a` or `b` work, and directly naming the unittest function also works
(`c`).

With 2.077, we get the error:
```
dummy.d-mixin-5(5): Error: undefined identifier __unittest_dummy_d_3_1, did you
mean function __unittest_dummy_d_3_1?
```

This regression was probably introduced by
https://github.com/dlang/dmd/pull/6727 , where the symbol name of unittest
function is set during semantic analysis probably too late for this identifier
resolution?

Note: the first unittest is needed to trigger the bug.

--
Dec 17 2017