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

NI1017 fails to report errors in certain expressions. #47

Open
gregr-ni opened this issue Dec 1, 2020 · 1 comment
Open

NI1017 fails to report errors in certain expressions. #47

gregr-ni opened this issue Dec 1, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@gregr-ni
Copy link
Collaborator

gregr-ni commented Dec 1, 2020

The code below should report an NI1017 error but does not because it is in the last section of a ternary operator. Errors in the first value of ternarys are reported correctly.

private static IEnumerable Ternary(IEnumerable numbers)
{
return numbers is null
? Enumerable.Empty()
: numbers.Where(n => n < 10).Select(n => $"{n}");
}

Likewise violations in a return statement are not reported. If you assign to a local then return the local, the error is reported.

private static int Expression(IEnumerable numbers)
{
return numbers.Where(n => n < 10).Select(n => n * 2).Max();
}

@Everest2020
Copy link
Contributor

The reason why it fails to report is because by registration

The syntax node in the second example is InvocationExpression
image

Have to check that node as the root node

@tsharma-ni tsharma-ni self-assigned this Jun 26, 2021
@tsharma-ni tsharma-ni added the bug Something isn't working label Jun 26, 2021
@tsharma-ni tsharma-ni removed their assignment Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants