PetTracker

PetTracker

12M Downloads

Bug in filter parsing

sirzooro opened this issue ยท 3 comments

commented

Running Software (issues missing this information will be deleted):

  • Addon version: 8.2.0
  • Server patch: [e.g. Build 8.2.0.31478]

Have you read the changelog? (please don't waste our time)
Yes

Describe the bug
For more complex filters result depends on order in which expression parts appears.

To Reproduce
Steps to reproduce the behaviour:
"missing | pet battle & !rare" - pets from professions are on map
"pet battle & !rare | missing" - pets from professions disappears
Both filters should display pets which are not collected, or are non-rare pets from battles.

Additionally display order depends on filter too - when icons for two pets overlaps, some of them are on top when 1st expression is used, and other ones when 2nd expression is used. This is a cosmetic issue, and it can be left as-is.

Expected behaviour
Both filters should give the same result.

commented

More examples:

  • "missing | pet battle & !rare | pt battle & rare & <23" - has typo "pt battle". This filter removed all pets for map;
  • "missing | pet battle & !rare | pet battle & rare & <23" - corrected version. It shows captureable non-rare pet with level below 23, but all non-rare capturable pets are gone.

Looks that there is something wrong with logic operators, at least they does not follow priorities usually implemented by programming languages (negation first, then AND, then OR).

BTW, In other issue here you wrote that that parenthesis are also not supported. This complicated things more, as casual addon users usually do not know De Morgan's laws.

commented

The wiki describes the order of operations. It works as described

commented

Wiki specifies following priorities:

  • comparison is the highest;
  • negation is next;
  • AND and OR are equal and lowest

There is no word about operator associativity, i.e. how addon evaluates expression when multiple operators with equal priorities are used.

Filter pet battle & !rare | missing does not include uncollected profession pets, so it must be evaluated as pet battle & (!rare | missing). However I have no idea about evaluation order for filter missing | pet battle & !rare | pet battle & rare & <23. I tried to analyze what will happen when it will be evaluated from right to left - it this case at least missing pets should be on map. I also checked possibility that OR may have higher priority than AND, but this also should show some pets on map.

Please tell me how exactly this addon evaluates this last expression. And please reconsider adding support for parenthesis. People learn about them early in school at math lessons, so this is not an advanced feature - it reality they will simplify creation of filters.