www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22579] New: Unittests defined in a template are instantiated


          Issue ID: 22579
           Summary: Unittests defined in a template are instantiated
                    indiscriminately in betterC mode AND cause inscrutable
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrei erdani.com

This is a twofer.

A top-level unittest that is not marked with  betterC in Phobos causes no
trouble in betterC mode. However, inside a template that's not the case:

template canon(string v)
        Object[] arr = [new A(1), new B(), null];

If client code instantiates this template the unittest will be materialized.

The second bug is that the line above causes an error message without a line or
any other information:

Error: `TypeInfo` cannot be used with -betterC

Dec 08 2021