Skip to content

No more guards for type pattern checks

Jordy Aaldering requested to merge yet-another-guard into develop

NoMoreGuardsProposal.pdf

Changes:

  • Removed type_fix prf
  • Removed guard_error prf
  • Removed type arguments from guard prf
    x1', .., xn' = guard(x1, .., xn, t1, .., tn, p1, .., pm)x1', .., xn' = guard(x1, .., xn, p1, .., pm)
  • Created new prf conditional_error
    acc' = conditional_error(acc, pred, "msg")
    Which returns true if both the accumulator and predicate are true, and false otherwise. By weaving in this accumulator we ensure that the function is not optimised away, and based on the predicate we are more likely to be able to print an error message already at compile-time.
  • Created a new global object rterror, which we use to weave in the accumulated value from conditional_error into the control flow. This approach seems to be better than the guards we had previously, as we now open the door to more optimisation potential again.
  • Remove no longer necessary WrapperFundef and CheckImplFundef from N_fundef AST node.
  • Cleanup type pattern test cases (ensure they always do -ecc -check c).
Edited by Jordy Aaldering

Merge request reports