Pattern-Script icon indicating copy to clipboard operation
Pattern-Script copied to clipboard

Expansion of rules can create a mix of valid and invalid rules

Open ClementSparrow opened this issue 3 years ago • 2 comments

(expansion, here, means both rule parameters expansion and properties expansions)

I'm still not sure how to deal with that, but this is a concern that deserves careful examination.

I'm not a fan of removing invalid rules silently as long as the expansion that produced them also produced valid rules. It is however useful sometimes and obviously matches what the dev had in mind. For instance, expanding rules like:

[ PropertyA PropertyA ] -> sfx0

...so that a rule is created for every pair of objects in different layers that are both PropertyA, but not for objects that are in the same layer. (Note that in that case, there is no real other way to do that than manually writing all rules for each pair of different layers, which is cumbersome and prone to error during the initial writing of the rules and in case of updates in the definition of PropertyA).

On the other hand, it makes the reporting of errors quite complicated. For instance, if half of the expanded rules get removed with some error message, and the other half of the expanded rules get also removed, but with a different error message.

And more importantly, there is always the possibility that the dev actually made a mistake, but the silent deletion of expansions with errors prevent the devs to notice their mistake, and lead them to a wild goose hunt for bugs in the wrong place.

ClementSparrow avatar Aug 16 '21 13:08 ClementSparrow

By invalid rule you mean one that tries to match the exact same object twice?

I don't see how you could handle that particular example except with code that explicitly looks for and drops the invalid rule. If you want something more general, you're probably going to have to start with a bunch of different repro cases.

david-pfx avatar Mar 12 '23 13:03 david-pfx

Well, in that case the rule would be valid, so my example above was a bad example. I guess the related issue #19 is a better example of what I had in mind. The general problem is to have a rule expanded, with some expansions compiling fine and some expansions compiling with errors that are silently discarded.

ClementSparrow avatar Mar 12 '23 14:03 ClementSparrow