Skip to content

Should the grammar allow ? in an old-style function-typed formal parameter declaration?  #364

Closed
@stereotype441

Description

@stereotype441

In the review of #293, @lrhn pointed out that:

There is no easy way to make a <functionFormalParameter> nullable. I suggest:

<functionFormalParameter> ::= \gnewline{}
    <metadata> \COVARIANT{}? <type>? <identifier> <formalParameterPart> `?'?

The final optional ? would make the function type of the parameter into a nullable function type, so:

  E firstWhere(bool test(E element), {E orElse()?});

would be valid.

When trying to convert dart:convert and dart:collection, I had a lot of optional function parameters which need to be nullable.

I'm filing this issue to track the decision about whether we want to make this change to the grammar, so that if we do, the analyzer team can find out about it and start work.

Metadata

Metadata

Assignees

Labels

nnbdNNBD related issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions