mirror of
https://github.com/Dummi26/mers.git
synced 2025-12-14 11:16:17 +01:00
improve panic function, add stacktrace
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user