Skip to content

Conversation

@gustavoaca1997
Copy link

This PR addresses #401

This is my first time contributing to a Tree Sitter grammar, so please let me know if you have any concerns, suggestions, extra test cases, etc.

Change details

  • Add new test cases to expressions.txt.
  • Modify the test case Array with trailing comma. Roselyn is actually matching [ y, ] against collection_expression, so I've updated the test to reflect that. I used SharpLab to verify that.
  • Add grammar rules for collection_element , expression_element , spread_element , collection_expression

How the changes were verified

I ran the tests locally, to verify they are passing.

@tris203
Copy link
Collaborator

tris203 commented Jan 19, 2026

I have updated ci
If you rebase and regenerate with 0.26.3 please

@gustavoaca1997
Copy link
Author

gustavoaca1997 commented Jan 19, 2026

I have updated ci If you rebase and regenerate with 0.26.3 please

Done @tris203 :) Thanks

@gustavoaca1997 gustavoaca1997 force-pushed the user/gustavoaca1997/fix-collection-expression branch from e54ff03 to 3685d1a Compare January 19, 2026 23:50
@gustavoaca1997
Copy link
Author

@tris203 I have force pushed the branch again, after accidentally the PR was showing changes that were already in the master branch

@gustavoaca1997
Copy link
Author

gustavoaca1997 commented Jan 20, 2026

@tris203 the files failing in the CI are valid C# 14, but are using expressions that are not yet supported: #392

These are the statements that are failing to be parsed in my branch, which should fail as well in master:

  • This line from PowerToys' ListViewModel. It has a Conditional Access Expression as a L-Value, which is still not supported in the current grammar.
 listPage.Filters?.CurrentFilterId = currentFilterId;
  • This line from PowerToys' CommandItemViewModel.cs. It also has a Conditional Access Expression as a L-Value,
_defaultCommandContextItemViewModel?.Command = Command;
  • This line from PowerToys' KernelServiceBase.cs. I believe this is a bug in the grammar, but that still could be solved by supporting Conditional Access Expressions as L-Values. I think it's a mistake that it is parsing the macros, instead of pre-processing the file, which is causing the Conditional Access Expression to be treated as an L-Value rather than the return expression of the lambda function.
static string Redact(object data) =>
#if DEBUG
            data?.ToString();
#else
            "[Redacted]";

It's possible that #400 fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants