mirror of
https://github.com/Dummi26/mers.git
synced 2025-04-28 18:16:05 +02:00
add _ wildcard for type definitions
and make line/file indicators in errors gray instead of fully white
This commit is contained in:
parent
945e19e10a
commit
1e2f0cb63c
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mers_lib"
|
name = "mers_lib"
|
||||||
version = "0.8.3"
|
version = "0.8.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "library to use the mers language in other projects"
|
description = "library to use the mers language in other projects"
|
||||||
|
@ -276,20 +276,28 @@ impl CheckError {
|
|||||||
if first_line_nr == last_line_nr {
|
if first_line_nr == last_line_nr {
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
"{}Line {first_line_nr} ({}..{}){}",
|
"{}",
|
||||||
indent!(true, false),
|
format!(
|
||||||
start_with_comments + 1 - first_line_start,
|
"{}Line {first_line_nr} ({}..{}){}",
|
||||||
end_with_comments - last_line_start,
|
indent!(true, false),
|
||||||
src_from,
|
start_with_comments + 1 - first_line_start,
|
||||||
|
end_with_comments - last_line_start,
|
||||||
|
src_from,
|
||||||
|
)
|
||||||
|
.bright_black()
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
"{}Lines {first_line_nr}-{last_line_nr} ({}..{}){}",
|
"{}",
|
||||||
indent!(true, false),
|
format!(
|
||||||
start_with_comments + 1 - first_line_start,
|
"{}Lines {first_line_nr}-{last_line_nr} ({}..{}){}",
|
||||||
end_with_comments - last_line_start,
|
indent!(true, false),
|
||||||
src_from,
|
start_with_comments + 1 - first_line_start,
|
||||||
|
end_with_comments - last_line_start,
|
||||||
|
src_from,
|
||||||
|
)
|
||||||
|
.bright_black()
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
let lines = if cfg.show_comments {
|
let lines = if cfg.show_comments {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use std::{fmt::Debug, sync::Arc};
|
use std::{fmt::Debug, sync::Arc};
|
||||||
|
|
||||||
|
use colored::Colorize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
data::{Data, Type},
|
data::{Data, Type},
|
||||||
errors::{CheckError, SourceRange},
|
errors::{CheckError, SourceRange},
|
||||||
@ -33,12 +35,25 @@ impl MersStatement for CustomType {
|
|||||||
if init_to.is_some() {
|
if init_to.is_some() {
|
||||||
return Err("can't init to `type` statement".to_string().into());
|
return Err("can't init to `type` statement".to_string().into());
|
||||||
}
|
}
|
||||||
let t = (self.source)(info)?;
|
let t = (self.source)(info);
|
||||||
info.scopes
|
if self.name != "_" {
|
||||||
.last_mut()
|
info.scopes
|
||||||
.unwrap()
|
.last_mut()
|
||||||
.types
|
.unwrap()
|
||||||
.insert(self.name.clone(), t);
|
.types
|
||||||
|
.insert(self.name.clone(), t?);
|
||||||
|
} else {
|
||||||
|
if let Err(e) = t {
|
||||||
|
return Err(CheckError::new()
|
||||||
|
.msg(format!(
|
||||||
|
" {} {} {} (`[[_] := ...]` indicates that `...` must be type-correct)",
|
||||||
|
"<<".bright_red(),
|
||||||
|
"Custom type-test failed!".bright_red(),
|
||||||
|
">>".bright_red(),
|
||||||
|
))
|
||||||
|
.err(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(Type::empty_tuple())
|
Ok(Type::empty_tuple())
|
||||||
}
|
}
|
||||||
fn run_custom(&self, _info: &mut Info) -> Data {
|
fn run_custom(&self, _info: &mut Info) -> Data {
|
||||||
|
Loading…
Reference in New Issue
Block a user