Skip to content

Cannot use '=>' syntax for declaring function to throw an exception #3370

Closed
@DartBot

Description

@DartBot

This issue was originally filed by [email protected]


What steps will reproduce the problem?

Object thrower(String msg) => throw new UnsupportedOperationException(msg);

What is the expected output? What do you see instead?

Defining the same function with curly braces works, but I don't see why I can't use the short form:

Error: line 1 pos 31: unexpected token 'throw'
Object thrower(String msg) => throw new UnsupportedOperationException(msg);

What version of the product are you using? On what operating system?

Dart SDK version 7904

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-duplicateClosed in favor of an existing report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions