Skip to content

Null propagation expression does not allow ! as a nested operator form (VS 16.8, .NET 5) #3393

@agocke

Description

@agocke

See dotnet/docs#17988

This means that the only correct parse of

var x = a?.b.c!.d.e;

is (a?.b.c)!.d.e, which prevents usage of null-forgiving in a chain of null-propagating accesses. To remedy this we could accept ! as an optional token after every simple name in the null-propagating non-terminal.

cc @jcouv @gafter


Was discussed in LDM 6/17/2020. There is agreement/support, but we'll need to investigate and make a concrete syntax proposal. Also, there is desire to keep terminal ! parsing as today: a?.b.c! would still parse as (a?.b.c)!.
For reference, the current syntax.

Metadata

Metadata

Assignees

Labels

Implemented Needs ECMA SpecThis feature has been implemented in C#, but still needs to be merged into the ECMA specificationProposal champion

Type

No type

Projects

Status

Done Umbrellas

Relationships

None yet

Development

No branches or pull requests

Issue actions