Skip to content

Commit f6ded50

Browse files
committed
impl syntaxerror
1 parent cadd656 commit f6ded50

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/codegen/src/compile.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,17 @@ impl Compiler {
21642164

21652165
// Compile exception type
21662166
if let Some(exc_type) = type_ {
2167+
// Check for unparenthesized tuple (e.g., `except* A, B:` instead of `except* (A, B):`)
2168+
if let Expr::Tuple(ExprTuple { elts, range, .. }) = exc_type.as_ref() {
2169+
if let Some(first) = elts.first() {
2170+
// If tuple starts at same column as first element, it's unparenthesized
2171+
if range.start().to_u32() == first.range().start().to_u32() {
2172+
return Err(self.error(CodegenErrorType::SyntaxError(
2173+
"multiple exception types must be parenthesized".to_owned(),
2174+
)));
2175+
}
2176+
}
2177+
}
21672178
self.compile_expression(exc_type)?;
21682179
} else {
21692180
return Err(self.error(CodegenErrorType::SyntaxError(

0 commit comments

Comments
 (0)