Skip to content

never return type for arrow functions with throw expressions #7900

Closed
@weirdan

Description

@weirdan

Description

The following code:

<?php

fn(): never => throw new Exception;

Resulted in this output:

Fatal error: A never-returning function must not return in /in/qWWuD on line 3

But I expected this output instead:

Obviously, it's caused by implicit return, but throw expressions never actually return.

PHP Version

8.1.x

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions