-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support target-type new expressions. #77
Comments
Note also that we don’t support interpolated strings appearing in declarations like these: private static readonly string s_defaultDocumentPath = @$"Document\Path\{DefaultDocumentName}”; |
new
I think this bug is more general than just constant declarators. |
new
new
expression without type.
Here’s a hack that fixes this: diff --git i/grammar.js w/grammar.js
index e6432dd..659783d 100644
--- i/grammar.js
+++ w/grammar.js
@@ -891,6 +891,14 @@ module.exports = grammar({
field('body', choice($.block, $._expression))
)),
+ direct_new_object_creation_expression: $ => seq(
+ 'new',
+ '(',
+ commaSep($._expression),
+ optional(','),
+ ')'
+ ),
+
anonymous_object_creation_expression: $ => seq(
'new',
'{',
@@ -1231,6 +1239,7 @@ module.exports = grammar({
_expression: $ => choice(
$.anonymous_method_expression,
$.anonymous_object_creation_expression,
+ $.direct_new_object_creation_expression,
$.array_creation_expression,
$.assignment_expression,
$.await_expression, |
The new without a type is a new C# 9 feature called target-type new expressions. This is the issue for it: dotnet/csharplang#100 So it is simply a new feature, not really a bug in the current syntax. |
This was a new feature in C# 8, where you can use wither I can create a PR to fix this. |
@initram Aha! I didn’t even notice that the characters were transposed. Thank you, and thanks for linking to the relevant chapter/verse of the standards. |
new
expression without type.
I think this issue can be closed now. |
Right now this fails to parse:
failing at the
= new(
bit. I think this is the relevant piece of syntax.The text was updated successfully, but these errors were encountered: