From bc60f1c8f14a6b56b333fb89a4c7a9b809a4c2e4 Mon Sep 17 00:00:00 2001 From: Brandon Lucas Date: Mon, 16 Feb 2026 23:40:15 -0500 Subject: [PATCH] fix: improve error message for bare 'run' expressions at top level When users write `run main() with {}` at top level instead of `let _ = run main() with {}`, provide a helpful error message explaining the correct syntax instead of the generic "Expected declaration" error. Co-Authored-By: Claude Opus 4.5 --- src/parser.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/parser.rs b/src/parser.rs index 5604d35..34d0f4d 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -244,6 +244,7 @@ impl Parser { TokenKind::Let => Ok(Declaration::Let(self.parse_let_decl(visibility, doc)?)), TokenKind::Trait => Ok(Declaration::Trait(self.parse_trait_decl(visibility, doc)?)), TokenKind::Impl => Ok(Declaration::Impl(self.parse_impl_decl()?)), + TokenKind::Run => Err(self.error("Bare 'run' expressions are not allowed at top level. Use 'let _ = run ...' or 'let result = run ...'")), _ => Err(self.error("Expected declaration (fn, effect, handler, type, trait, impl, or let)")), } }