In the following example, y is treated as an export, even though it's a local variable like b.
import core.stdc.stdio : printf;
void main() { printf("result is %d\n", foo(10)); }
alias foo = fooMaker!((int x) {
int y = x + 1;
return y;
});
int fooMaker(alias cb)(int a) {
int b = a + 1;
return cb(b);
}
If I run dub run dscanner -- --ctags a.d, I get:
!_TAG_FILE_FORMAT 2
!_TAG_FILE_SORTED 1
!_TAG_FILE_AUTHOR Brian Schott
!_TAG_PROGRAM_URL https://github.com/dlang-community/D-Scanner/
foo a.d 5;" a line:5
main a.d 3;" f line:3 signature:()
y a.d 6;" v line:6
Thankfully the workaround is simple: Use a named function:
alias foo = fooMaker!fooInner;
private int fooInner(int x) {
int y = x + 1;
return y;
}
In the following example,
y
is treated as an export, even though it's a local variable likeb
.If I run
dub run dscanner -- --ctags a.d
, I get:Thankfully the workaround is simple: Use a named function: