Skip to content

try blocks don't parse after return #76271

@scottmcm

Description

@scottmcm

Simple demo that won't compile but should be a type error:

#![feature(try_blocks)] fn demo() { return try { 4 }; }

But it gives a parse error instead:

error: expected one of `.`, `;`, `?`, `}`, or an operator, found reserved keyword `try` --> src/lib.rs:3:12 | 3 | return try { 4 }; | ^^^ expected one of `.`, `;`, `?`, `}`, or an operator error: aborting due to previous error 

(It works if you put parens, like return (try { 4 });)

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTB-unstableBlocker: Implemented in the nightly compiler and unstable.C-bugCategory: This is a bug.F-try_blocks`#![feature(try_blocks)]`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions