diff --git a/src/ast2/mod.rs b/src/ast2/mod.rs index a72f756..191cad5 100644 --- a/src/ast2/mod.rs +++ b/src/ast2/mod.rs @@ -3350,23 +3350,24 @@ pub mod ast_gen { fn parse_array_type(&mut self, tokens: &mut TokenIterator) -> ParseResult { let loc = tokens.current_source_location(); let length_expr = self.parse_bracketed(tokens, |this, tokens| { - let next = tokens.peek_token().ok_or(ErrorInfo { - error: ParseError::UnexpectedEndOfTokens, - loc: tokens.current_source_location(), - })?; - match next.token() { - Token::IntegerBinConstant - | Token::IntegerHexConstant - | Token::IntegerOctConstant - | Token::IntegerConstant => { - _ = tokens.next(); - Ok(this.parse_integral_constant(&next, next.source_location())) - } - _ => Err(ErrorInfo { - error: ParseError::ExpectedConstantLiteral, - loc: tokens.current_source_location(), - }), - } + this.parse_expr(tokens) + // let next = tokens.peek_token().ok_or(ErrorInfo { + // error: ParseError::UnexpectedEndOfTokens, + // loc: tokens.current_source_location(), + // })?; + // match next.token() { + // Token::IntegerBinConstant + // | Token::IntegerHexConstant + // | Token::IntegerOctConstant + // | Token::IntegerConstant => { + // _ = tokens.next(); + // Ok(this.parse_integral_constant(&next, next.source_location())) + // } + // _ => Err(ErrorInfo { + // error: ParseError::ExpectedConstantLiteral, + // loc: tokens.current_source_location(), + // }), + // } })?; let &[cnst, vol, noalias] = diff --git a/tests/legal/array.sea b/tests/legal/array.sea index 4143eb4..532cebc 100644 --- a/tests/legal/array.sea +++ b/tests/legal/array.sea @@ -1,4 +1,4 @@ fn main() { var arr: [4] u8; arr[0] = 1; -} \ No newline at end of file +} diff --git a/tests/legal/array_complex.sea b/tests/legal/array_complex.sea new file mode 100644 index 0000000..617309f --- /dev/null +++ b/tests/legal/array_complex.sea @@ -0,0 +1,6 @@ +const ARRAY_SIZE: usize = 16; + +fn main() { + var arr: [ARRAY_SIZE << 1] u8; + arr[0] = 1; +} diff --git a/tests/legal/comptime.sea b/tests/legal/comptime.sea new file mode 100644 index 0000000..89bf4fc --- /dev/null +++ b/tests/legal/comptime.sea @@ -0,0 +1,6 @@ +const RANDOM: u32 = (3 + 54*5) >> 3; + +fn main() -> u32 { + let a: u32 = (3 + 54*5) >> 3; + RANDOM +}