improve panic function, add stacktrace

This commit is contained in:
Mark
2024-06-19 12:35:23 +02:00
parent 4770e3f939
commit cd21c2171e
35 changed files with 367 additions and 232 deletions

View File

@@ -43,7 +43,7 @@ fn parse_compile_check_run(src: String) -> Result<(Type, Data), CheckError> {
// check (this step is optional, but if it is skipped when it would have returned an error, `run` will likely panic)
let output_type = compiled.check(&mut i3, None)?;
// run
let output_value = compiled.run(&mut i2);
let output_value = compiled.run(&mut i2)?;
// check that the predicted output type was correct
assert!(output_value.get().as_type().is_included_in(&output_type));
// return the produced value

View File

@@ -23,7 +23,7 @@ fn main() -> Result<(), CheckError> {
// use the function to decorate these 3 test strings
for input in ["my test string", "Main Menu", "O.o"] {
let result = func.run(Data::new(data::string::String(input.to_owned())));
let result = func.run(Data::new(data::string::String(input.to_owned())))?;
let result = result.get();
let result = &result
.as_any()
@@ -44,6 +44,6 @@ fn parse_compile_check_run(src: String) -> Result<(Type, Data), CheckError> {
let (mut i1, mut i2, mut i3) = Config::new().bundle_std().infos();
let compiled = parsed.compile(&mut i1, CompInfo::default())?;
let output_type = compiled.check(&mut i3, None)?;
let output_value = compiled.run(&mut i2);
let output_value = compiled.run(&mut i2)?;
Ok((output_type, output_value))
}

View File

@@ -48,7 +48,7 @@ fn run(src: String) -> Result<(), CheckError> {
.downcast_ref::<data::string::String>()
.unwrap()
.0;
Data::new(data::string::String(arg.chars().rev().collect()))
Ok(Data::new(data::string::String(arg.chars().rev().collect())))
},
)),
)
@@ -56,6 +56,6 @@ fn run(src: String) -> Result<(), CheckError> {
let compiled = parsed.compile(&mut i1, CompInfo::default())?;
compiled.check(&mut i3, None)?;
compiled.run(&mut i2);
compiled.run(&mut i2)?;
Ok(())
}