Skip to content

Support inferring the return value of functions #4280

Open
@rrousselGit

Description

@rrousselGit

With records, it becomes tempting to rely more on type-inference. Inference is important for records, because it avoids lots of repetition

The problem is, inference for the return value of function is only available with closures:

// Inferred as ({String name, int age}) Function()
final example = () => (name: '', age: 42);

If we use a "normal" function, we are forced to specify the return value:

({String name, int age}) example() => (name: '', age: 42);

Proposal

It'd be cool to have a mean to define classical functions, but infer the value. One possibility could be:

infer example() => (name: '', age: 42);

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions