Skip to content

"implicit, semicolonless return" doesn't work if followed by an inner function #3054

Description

@bblum
fn main() {
    x()
    fn x() -> () { () }
}

produces:

what.rs:3:4: 3:6 error: expected `;` or `}` after expression but found `fn`
what.rs:3     fn x() -> () { () }
              ^~

The workaround is easy - you just write ret x(); explicitly. But maybe it's possible that we not have to?

Knowing nothing about parsing, I'm not sure if this can be resolved unambiguously, but I figured I'd mention it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-grammarArea: The grammar of Rust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions