Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable in a lambda template argument is considered an export by --ctags #867

Open
andy-hanson opened this issue Apr 30, 2022 · 0 comments
Labels

Comments

@andy-hanson
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants