mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-14 11:16:17 +01:00
improved error messages
- some small bugs are now fixed - include comments in error messages (if this causes issues, use --hide-comments) - colors should make more sense now - error-related things moved to mers_lib/src/errors/
This commit is contained in:
@@ -5,7 +5,8 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
data::{self, Data, MersType, Type},
|
||||
program::run::{CheckError, CheckInfo, Info},
|
||||
errors::CheckError,
|
||||
program::run::{CheckInfo, Info},
|
||||
};
|
||||
|
||||
use super::Config;
|
||||
|
||||
@@ -9,10 +9,8 @@ use crate::{
|
||||
function::{Function, FunctionT},
|
||||
Data, MersData, MersType, Type,
|
||||
},
|
||||
program::{
|
||||
self,
|
||||
run::{CheckError, CheckInfo},
|
||||
},
|
||||
errors::CheckError,
|
||||
program::{self, run::CheckInfo},
|
||||
};
|
||||
|
||||
use super::Config;
|
||||
@@ -140,13 +138,6 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
fn iter_out(
|
||||
a: &Type,
|
||||
name: &str,
|
||||
func: impl Fn(&FunctionT) -> ItersT + Sync + Send,
|
||||
) -> Result<Type, CheckError> {
|
||||
iter_out_arg(a, name, func)
|
||||
}
|
||||
fn iter_out_arg<T: MersType>(
|
||||
a: &Type,
|
||||
name: &str,
|
||||
|
||||
@@ -135,7 +135,7 @@ impl Config {
|
||||
Data::new(data::function::Function {
|
||||
info: Arc::new(program::run::Info::neverused()),
|
||||
info_check: Arc::new(Mutex::new(CheckInfo::neverused())),
|
||||
out: Arc::new(|a, i| {
|
||||
out: Arc::new(|a, _i| {
|
||||
if let Some(v) = a.iterable() {
|
||||
Ok(Type::new(ListT(v)))
|
||||
} else {
|
||||
|
||||
@@ -2,10 +2,8 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::{
|
||||
data::{self, Data, MersType, Type},
|
||||
program::{
|
||||
self,
|
||||
run::{CheckError, CheckInfo},
|
||||
},
|
||||
errors::CheckError,
|
||||
program::{self, run::CheckInfo},
|
||||
};
|
||||
|
||||
use super::Config;
|
||||
|
||||
@@ -6,10 +6,8 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
data::{self, Data, MersData, MersType, Type},
|
||||
program::{
|
||||
self,
|
||||
run::{CheckError, CheckInfo},
|
||||
},
|
||||
errors::CheckError,
|
||||
program::{self, run::CheckInfo},
|
||||
};
|
||||
|
||||
use super::Config;
|
||||
|
||||
@@ -3,8 +3,11 @@ use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use colored::Colorize;
|
||||
|
||||
use crate::{
|
||||
data::{self, Data, Type},
|
||||
errors::error_colors,
|
||||
program::{self, run::CheckInfo},
|
||||
};
|
||||
|
||||
@@ -23,7 +26,17 @@ impl Config {
|
||||
Data::new(data::function::Function {
|
||||
info: Arc::new(program::run::Info::neverused()),
|
||||
info_check: Arc::new(Mutex::new(CheckInfo::neverused())),
|
||||
out: Arc::new(|a, i| Ok(Type::new(data::string::StringT))),
|
||||
out: Arc::new(|a, _i| {
|
||||
if a.is_zero_tuple() {
|
||||
Ok(Type::new(data::string::StringT))
|
||||
} else {
|
||||
Err(format!(
|
||||
"expected (), got {}",
|
||||
a.to_string().color(error_colors::FunctionArgument)
|
||||
)
|
||||
.into())
|
||||
}
|
||||
}),
|
||||
run: Arc::new(|_a, _i| {
|
||||
let mut line = String::new();
|
||||
_ = std::io::stdin().read_line(&mut line);
|
||||
@@ -36,7 +49,7 @@ impl Config {
|
||||
Data::new(data::function::Function {
|
||||
info: Arc::new(program::run::Info::neverused()),
|
||||
info_check: Arc::new(Mutex::new(CheckInfo::neverused())),
|
||||
out: Arc::new(|a, i| Ok(Type::empty_tuple())),
|
||||
out: Arc::new(|_a, _i| Ok(Type::empty_tuple())),
|
||||
run: Arc::new(|a, _i| {
|
||||
eprintln!("{:#?}", a.get());
|
||||
Data::empty_tuple()
|
||||
@@ -48,10 +61,10 @@ impl Config {
|
||||
Data::new(data::function::Function {
|
||||
info: Arc::new(program::run::Info::neverused()),
|
||||
info_check: Arc::new(Mutex::new(CheckInfo::neverused())),
|
||||
out: Arc::new(|a, i| Ok(Type::empty_tuple())),
|
||||
out: Arc::new(|_a, _i| Ok(Type::empty_tuple())),
|
||||
run: Arc::new(|a, _i| {
|
||||
eprint!("{}", a.get());
|
||||
std::io::stderr().lock().flush();
|
||||
_ = std::io::stderr().lock().flush();
|
||||
Data::empty_tuple()
|
||||
}),
|
||||
}),
|
||||
@@ -61,7 +74,7 @@ impl Config {
|
||||
Data::new(data::function::Function {
|
||||
info: Arc::new(program::run::Info::neverused()),
|
||||
info_check: Arc::new(Mutex::new(CheckInfo::neverused())),
|
||||
out: Arc::new(|a, i| Ok(Type::empty_tuple())),
|
||||
out: Arc::new(|_a, _i| Ok(Type::empty_tuple())),
|
||||
run: Arc::new(|a, _i| {
|
||||
eprintln!("{}", a.get());
|
||||
Data::empty_tuple()
|
||||
@@ -73,10 +86,10 @@ impl Config {
|
||||
Data::new(data::function::Function {
|
||||
info: Arc::new(program::run::Info::neverused()),
|
||||
info_check: Arc::new(Mutex::new(CheckInfo::neverused())),
|
||||
out: Arc::new(|a, i| Ok(Type::empty_tuple())),
|
||||
out: Arc::new(|_a, _i| Ok(Type::empty_tuple())),
|
||||
run: Arc::new(|a, _i| {
|
||||
print!("{}", a.get());
|
||||
std::io::stdout().lock().flush();
|
||||
_ = std::io::stdout().lock().flush();
|
||||
Data::empty_tuple()
|
||||
}),
|
||||
}),
|
||||
@@ -86,7 +99,7 @@ impl Config {
|
||||
Data::new(data::function::Function {
|
||||
info: Arc::new(program::run::Info::neverused()),
|
||||
info_check: Arc::new(Mutex::new(CheckInfo::neverused())),
|
||||
out: Arc::new(|a, i| Ok(Type::empty_tuple())),
|
||||
out: Arc::new(|_a, _i| Ok(Type::empty_tuple())),
|
||||
run: Arc::new(|a, _i| {
|
||||
println!("{}", a.get());
|
||||
Data::empty_tuple()
|
||||
|
||||
Reference in New Issue
Block a user