www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18488] New: test_extractor misses version(unittest) blocks,

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

          Issue ID: 18488
           Summary: test_extractor misses version(unittest) blocks,
                    causing `Deprecation: X is not visible from Y`
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: tools
          Assignee: nobody puremagic.com
          Reporter: timothee.cour2 gmail.com

eg:

occurred in https://github.com/dlang/phobos/pull/6178

```
module bar;
vesion(unittest){
void foo(){}
}

unittest{
foo;
}
```

Deprecation: foo is not visible from bar

The solution would be for test_extractor to export `vesion(unittest)`
declarations.

This would be easy to do if
https://github.com/dlang-community/libdparse/issues/191 (Add precise source

declarations)

the change would be something like:

```
override void visit(const Declaration decl){

        auto u2=decl.conditionalDeclaration;
        if(!u2) return;
        auto u3=u2.compileCondition.versionCondition;
        if(!u3) return;
        auto token=u3.token;
        import dparse.lexer:tok;
        if(token.type!=tok!"unittest") return;

        foreach(ui;u2.trueDeclarations){
            print(ui);  // this would need to access start and end locations of
decl
        }

}


```

--
Feb 22 2018