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: nob...@puremagic.com
          Reporter: timothee.co...@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
locations (start and end) to each ASTNode #191) was fixed (at least for
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
        }

}


```

--

Reply via email to