Skip to content

Commit ad8aacf

Browse files
GearsDatapackslpil
authored andcommitted
Only error in statement position
1 parent c7ee6be commit ad8aacf

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

compiler-core/src/parse.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,14 +808,6 @@ where
808808
return parse_error(ParseErrorType::ExprLparStart, SrcSpan { start, end: start });
809809
}
810810

811-
// Helpful error when trying to define a constant inside a function.
812-
Some((start, Token::Const, end)) => {
813-
return parse_error(
814-
ParseErrorType::ConstantInsideFunction,
815-
SrcSpan { start, end },
816-
);
817-
}
818-
819811
// Boolean negation
820812
Some((start, Token::Bang, _end)) => {
821813
self.advance();
@@ -1190,6 +1182,12 @@ where
11901182
Ok(Some(self.parse_assert(start)?))
11911183
}
11921184

1185+
// Helpful error when trying to define a constant inside a function.
1186+
Some((start, Token::Const, end)) => parse_error(
1187+
ParseErrorType::ConstantInsideFunction,
1188+
SrcSpan { start, end },
1189+
),
1190+
11931191
token => {
11941192
self.tok0 = token;
11951193
self.parse_statement_errors()?;

0 commit comments

Comments
 (0)