Closed Halbaroth closed 5 months ago
I believe there are still places where we can create unsorted triggers, namely from backwards_triggers
, forward_triggers
and make
itself.
I am a bit concerned about the potential for subtle bugs if unsorted triggers make their way to the matching
function; I'd like to at least have a debug assertion that the triggers are sorted at that point.
Good catch! I didn't notice they created new triggers!
As we noticed a long time ago, the
Matching
module of Alt-Ergo sorts patterns of multi-triggers during each iteration of the matching round. It's inefficient as the weight used for sorting doesn't change.I thought we should perform these sorts during the generation of triggers in
Expr
but actually, Alt-Ergo can generate new triggers later depending on the matching configuration (seeUtil.matching_env
).In this PR, we perform the sorts just before caching the generated triggers in
Matching
.