ejrgilbert / whamm

5 stars 2 forks source link

Missing error in phase phase #40

Open ahuoguo opened 3 weeks ago

ahuoguo commented 3 weeks ago

The following program (copy to src/parser/tests.rs)

#[test]
pub fn test_whamm_try() {
    setup_logger();
    let script = r#"
wasm::call:alt /
    target_fn_type == "import" &&
    target_imp_module == "ic0" &&
    target_imp_name == "call_new" &&
    strpaircmp((arg0, arg1), "bookings") &&
    strpaircmp((arg2, arg3), "record")
/ {
    try((arg0, arg1), "bookings");
}
    whamm::br:before / i == 1 / { i = 0; }  // SHOULD FAIL HERE
    "#;
    let mut err = ErrorGen::new("".to_string(), "".to_string(), 0);

    match get_ast(script, &mut err) {
        Some(ast) => {
            // script
            print_ast(&ast);
        },
        None => {
            error!("Could not get ast from script: {}", script);
            err.report();
            assert!(false);
        }
    };
}

should failed with an error like this:

error[ParsingError]: Could not find any matches for this pattern
 --> :2:12
  | 
2 |     whamm::br:before / i == 1 / { i = 0; }  // split out an error q
  |            ^^ Could not find any matches for this pattern
  | 
error: test failed, to rerun pass `-p whamm --lib`

but it passes parsing, ignoring the event br. (see printed AST)

Should be some processing logic error at process_pair in src/parser/types.rs

wavid-b commented 2 weeks ago

I think br is just unimplemented yet, so it should pass parsing tests but not further ones yet

ahuoguo commented 2 weeks ago

Yes the emitter for br is unimplemented. But the check that whamm doesn't contain event br should be done at parser phase.

wavid-b commented 1 week ago

Changing this bug -- the real issue is that any probe after the first is not being processes into the AST

wavid-b commented 1 week ago

additional issue - statements after the first probe_def error --EDIT: FIXED

wavid-b commented 1 week ago

The issue is in add_probe() When is_empty removes the provider from the list, it removes it for other probes in the script There shouldn't be a check if providers list is empty before throwing an error

ahuoguo commented 1 week ago

This should be solved in the parser rework #64