-
Notifications
You must be signed in to change notification settings - Fork 747
Description
Following on from #2710, which pointed out that previously the csharp lexer was not properly identifying new contextual keywords as keywords, I looked at some contexts in which the current solution might overgeneralise. Here is an example (not good C#, but an effective illustration):
As can be seen (and confirmed by viewing the output through the raw formatter), the current code is treating almost every instance of "file" as a keyword.
In case it isn't clear in the image, the code used to produce the image above is as follows:
file record X(int file);
file record Y(int blah);
public static class Program {
static int file(Func<int,int> file) => file(13);
static int blah(Func<int,int> blah) => blah(13);
public static void Main(string[] args) {
int file = Program.file(file => 42);
int blah = Program.blah(blah => 12);
X x = new(9);
Console.WriteLine($"{file}{blah}{x}{args}");
}
}I wonder if the results could be improved by only recognising "file" as a keyword if it is followed by something like "record", "class", or "enum", and how many of the other contextual keywords would be susceptible to similar handling.
