Fix bugs, add propper tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use anyhow::{Result, bail};
|
||||
|
||||
use crate::{cli::CliArgs, common::loc::LocBox, lerror, parser::{Delimiter, ast::{expr::Expr, literal::Literal}}, tokeniser::Token};
|
||||
use crate::{cli::CliArgs, common::loc::LocBox, lerror, parser::{Delimiter, ast::{Program, expr::Expr, literal::Literal}}, tokeniser::Token, validator::predefined::get_builtin_from_name};
|
||||
|
||||
use super::{ast::{typ::Type, TokenType}, expr::parse_expr, utils, Keyword, Punctuation};
|
||||
|
||||
@@ -25,7 +25,7 @@ pub fn parse_type(tokens: &mut Vec<Token>) -> Result<LocBox<Type>> {
|
||||
}
|
||||
let itm_typ = parse_type(tokens)?;
|
||||
if let Some(_) = utils::check_consume(tokens, TokenType::Punct(Punctuation::Semi)) {
|
||||
let count = parse_expr(tokens, 0, false, &CliArgs::default())?.unwrap();
|
||||
let count = parse_expr(tokens, 0, false, &CliArgs::default(), &mut Program::default())?.unwrap();
|
||||
|
||||
match count.inner() {
|
||||
Expr::Literal(_, Literal::Number(_)) |
|
||||
@@ -47,7 +47,11 @@ pub fn parse_type(tokens: &mut Vec<Token>) -> Result<LocBox<Type>> {
|
||||
_ = 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());
|
||||
if let Some(t) = get_builtin_from_name(&ident.tt().unwrap_ident().0) {
|
||||
typ = t;
|
||||
} else {
|
||||
typ = Type::Owned(ident.tt().unwrap_ident());
|
||||
}
|
||||
if let None = loc {
|
||||
loc = Some(ident.loc().clone());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user