Skip to content

[Proposal]: Conditional operator/access syntax refinement #9778

@CyrusNajmabadi

Description

@CyrusNajmabadi

Conditional-expression/access syntax refinement.

Summary

Introduce whitespace-sensitive parsing rules to eliminate ambiguity between the conditional operator (?:)
and null-conditional access operators (?. and ?[). This change requires that tokens in null-conditional
operators must be adjacent with no intervening characters, while conditional operators with certain operand
patterns must have whitespace or comments between the ? and the subsequent token.

For example: a?[ will always be interpreted to be the start of a conditional index into a (e.g. a?[b]). In other words, indexing into a with some arguments that follow the [ if a is non-null. Whereas a? [ will always be interpreted to be the start of a condition expression (e.g. a ? [b] : ...). So a test if a is true or not, and returning a collection expression if so.

Design meetings

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions