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

Is this a bug that lambda discards aren't highlighted as keyword? #51553

Closed
KyouyamaKazusa0805 opened this issue Mar 1, 2021 · 12 comments
Closed
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@KyouyamaKazusa0805
Copy link

KyouyamaKazusa0805 commented Mar 1, 2021

Version Used:
VS 16.9 Preview 5

Steps to Reproduce:

var model = ViewModel.PanelViewModel;

model.GridChanged += (SudokuPanelViewModel _, in SudokuGrid _) => ViewModel.Image = ViewModel.Generator.Paint();

Expected Behavior:

Both two underscore _ in SudokuPanelViewModel _ and in SudokuGrid _ should be highlighted as keyword (I mean, in blue as same color as keyword highlights).

Actual Behavior:

The color doesn't change no matter how I change the code (Lambdas, anonymous functions...)

Screenshots:

1

2

3

4

For the last picture, I don't know whether the syntax is valid. I just test the cases that makes the discards to be highlighted as keywords.


Update (2022/8/15):

It seems that the discard highlights behave differently between light and dark themes.

In dark theme, discards are not highlighted correctly:

image

But in light theme, discards are displayed successfully:

image


Update (2023/12/1):

I think it has been fixed.

image

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 1, 2021
@KyouyamaKazusa0805 KyouyamaKazusa0805 changed the title Is this a bug that lambda discards isn't highlighted as keyword? Is this a bug that lambda discards aren't highlighted as keyword? Mar 1, 2021
@hez2010
Copy link

hez2010 commented Mar 1, 2021

I think discard _ is not a keyword, it's a valid identifier.

@jmarolf
Copy link
Contributor

jmarolf commented Mar 1, 2021

upvote dotnet/csharplang#4460

@KyouyamaKazusa0805
Copy link
Author

@jmarolf @hez2010

Hmmmm... In fact I mean the discards will be highlighted as blue.

Snipaste_2021-03-01_21-01-21

Only lambda parameters (_) is in white, while other discards are in blue.

@jnm2
Copy link
Contributor

jnm2 commented Mar 1, 2021

I noticed this as well. It would be nice for the visual cue to work based on semantics with parameter discards like with other discards.

@KyouyamaKazusa0805
Copy link
Author

I noticed this as well. It would be nice for the visual cue to work based on semantics with parameter discards like with other discards.

Yeah, that's it!

@CyrusNajmabadi
Copy link
Member

It should be. Sounds like a bug. PRs welcome.

@KyouyamaKazusa0805
Copy link
Author

It should be. Sounds like a bug. PRs welcome.

@CyrusNajmabadi XD

I've been learning the Roslyn source code, but I don't think I have any ability to create a PR at present.

If I have the ability, I will. :)

@jinujoseph jinujoseph added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 2, 2021
@jinujoseph jinujoseph added this to the Backlog milestone Mar 2, 2021
@Youssef1313
Copy link
Member

Youssef1313 commented Mar 6, 2021

This is weird. It is already tested 😱

[Theory]
[CombinatorialData]
public async Task DiscardsInLambda(TestHost testHost)
{
await TestAsync(@"
class X
{
void N()
{
System.Func<int, int, int> a = (int _, int _) => 0;
}
}",
testHost,
Namespace("System"),
Delegate("Func"),
Keyword("_"),
Keyword("_"));
}

For reference: this was added in #40396. But for some weird reason it doesn't work despite the test is passing.

The following code may be related (not sure) - but still, the test should have failed:

else if (token.Parent is ParameterSyntax parameterSyntax && parameterSyntax.Identifier == token)
{
return ClassificationTypeNames.ParameterName;
}

@Youssef1313
Copy link
Member

Youssef1313 commented Mar 6, 2021

The semantic classifier works correctly, but the syntactic one doesn't (at least this is what the tests say). This causes SemanticClassifierTests to pass, while things doesn't actually work. @CyrusNajmabadi Is there a way to order the semantic classifier to be run after the syntactic classifier?

@CyrusNajmabadi
Copy link
Member

I believe we have 'total classifier' tests

@KyouyamaKazusa0805

This comment was marked as duplicate.

@KyouyamaKazusa0805
Copy link
Author

Close this issue. This issue is solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: Completed
Development

No branches or pull requests

7 participants