Fix array type parsing, where it crashes with "IOT instruction, stack overflow"
This commit is contained in:
parent
8bb0e28d80
commit
6c01265f0b
|
@ -1,6 +1,6 @@
|
|||
use anyhow::Result;
|
||||
|
||||
use crate::tokeniser::Token;
|
||||
use crate::{parser::Delimiter, tokeniser::Token};
|
||||
|
||||
use super::{ast::{typ::Type, TokenType}, expr::parse_expr, utils, Keyword, Punctuation};
|
||||
|
||||
|
@ -15,7 +15,7 @@ pub fn parse_type(tokens: &mut Vec<Token>) -> Result<Type> {
|
|||
}
|
||||
|
||||
let mut typ;
|
||||
if let Some(_) = utils::check(tokens, TokenType::Delim(super::Delimiter::SquareL)) {
|
||||
if let Some(_) = utils::check_consume(tokens, TokenType::Delim(super::Delimiter::SquareL)) {
|
||||
let itm_typ = parse_type(tokens)?;
|
||||
if let Some(_) = utils::check_consume(tokens, TokenType::Punct(Punctuation::Semi)) {
|
||||
let count = parse_expr(tokens, 0, false)?.unwrap();
|
||||
|
@ -28,6 +28,7 @@ pub fn parse_type(tokens: &mut Vec<Token>) -> Result<Type> {
|
|||
inner: Box::new(itm_typ),
|
||||
}
|
||||
}
|
||||
_ = utils::check_consume_or_err(tokens, TokenType::Delim(Delimiter::SquareR), "")?;
|
||||
} else {
|
||||
let ident = utils::check_consume_or_err(tokens, TokenType::ident(""), "a")?;
|
||||
typ = Type::Owned(ident.tt().unwrap_ident());
|
||||
|
|
Loading…
Reference in New Issue
Block a user