[E][P] Inconsistent variable to variable less/greater comparisons

Post about any bugs or other issues that you find on AAO.

Moderator: EN - Forum Moderators

Post Reply
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

[E][P] Inconsistent variable to variable less/greater comparisons

Post by TimeAxis »

User Agent String: Tested on both Firefox and Chrome
Link: https://aaonline.fr/player.php?trial_id=142000 see second post for better example of the problem
What did you expect to happen?: In an "Evaluate conditions to redirect the player", I am using the expression "variableA > variableB" to go to frame 3 if variableA (set to 10) is greater than variableB (set to 5), and go to frame 4 otherwise. It should go to 3, as 10 is greater than 5.
What happened?: variableA being greater than variableB is not recognized and I'm sent to frame 4. Then, when I try "variableA < variableB", it is recognized as being less, despite that being incorrect. However, when I use "variableA > 5" it is correctly recognized as being greater than 5, so this problem only exists with variable to variable comparisons.
Can you reproduce the problem?: Yes, seen in the quick example trial linked above
What did you do before the problem showed up?: Nothing. The example trial contains the entire bug in a vacuum, displayed a number of ways. The example in the next post is a more complete example.

This bug has an easy workaround in that, knowing the results will be backwards, you can simply account for that in case logic. But that means any cases built on that logic will break once this bug is fixed.
Last edited by TimeAxis on Sat Mar 19, 2022 10:23 am, edited 5 times in total.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by TimeAxis »

Okay, this is actually a bit more complicated than I thought. With some variables it's reversed, and with others, in very similar contexts, it's not. The differing factor seems to be their values. Single digit values seem to be the deciding factor.

I've made a new example trial to show off what I mean:
User Agent String: Tested on both Firefox and Chrome
Link: https://aaonline.fr/player.php?trial_id=142007
What did you expect to happen?: variables nine=9, ten= 10, twelve = 12. "nine < ten" and "nine < twelve" should return true. "9 < ten" and "ten < twelve" should also return true.
What happened?: "nine < ten" and "nine < twelve" return false. "9 < ten" return true. "ten < twelve" returns true.

The only workaround to this would seem to be to add 10 to all of your variables before comparing them.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
User avatar
Enthalpy
Community Manager
Posts: 5169
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by Enthalpy »

Thanks for the report. I'm going to be busy this morning, but I'm hopeful I can look into it this afternoon. Demonstration trials are greatly appreciated!
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
User avatar
Enthalpy
Community Manager
Posts: 5169
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by Enthalpy »

I've looked into this, and I don't think it's a bug so much as evidence that the documentation on how to use the expression engine needs to be expanded.

Look at this trial. In one case, I set variables equal to 9 and 10 as runtime expressions and in the other not as runtime expressions. In the runtime expression case, 9 and 10 mean the numbers, and we get the behavior you expect. In the non-runtime expression case, 9 and 10 means the strings of characters '9' and '10'. 9 < 10 is true, and '9' < '10' is true, because of how comparison of strings is defined.

I should update my variable guide to elaborate on runtime expressions...
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by TimeAxis »

That does explain it, but it also renders variables as a whole significantly more clunky to use in all practical situations.

I’d make the suggestion for it to not work that way. Default behavior should be that numbers are treated as numbers and if you want the string of the number for some reason, then you’d use a runtime expression and add quotes.

An alternative compromise if that’s not an option would be to at least make the > and < operators parse integers like the + operator does, since there are very few practical situations I can think of where you’d ever want to compare strings in that way.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
User avatar
Enthalpy
Community Manager
Posts: 5169
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by Enthalpy »

None of that is viable. Changing how the expression engine parses things could break too many old cases. Documentation is the better solution.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by TimeAxis »

I can't imagine the number of cases that rely on strings being compared with > or < (something I would need to work hard to even fathom a use case for, which seems like an oversight in the first place rather than intended behavior) would exceed single digits, if any exist at all. And that's assuming said specific old cases pass the first check of not being already rendered essentially unplayable due to graphics or sounds no longer loading. If preserving compatibility with that obscure functionality was something you really wanted, attempting to parse as an integer first before defaulting to string on failure would render it working the same in all practical cases. If you mean cases that for some reason rely on the misuse pointed out in this thread, built around faulty logic, I don't think compatibility should be prioritized in those cases. Adding extra documentation for workarounds as a substitute for making something work better seems very short-sighted to me, and like a recipe for excessive documentation baggage and increasing user-unfriendliness.

But in any case, the "bug" has been cleared up, so thank you.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
User avatar
Enthalpy
Community Manager
Posts: 5169
Joined: Wed Jan 04, 2012 4:40 am
Gender: Male
Spoken languages: English, limited Spanish

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by Enthalpy »

If you want to say that I'm not properly estimating some impact of this proposal, that's well and good. But you're making it sound like some people deserve to have their cases broken and that there's no justifiable reason to disagree with you. Tone it down.

I did some experimenting in the editor and found a "fun" example. If you define foo and bar to both be 2 and define a variable as the runtime expression foo + bar, the result you get is 4 - so now they're adding like integers rather than strings. That's inconsistent with string behavior. To me, that is a compelling argument to change the expression engine.

This is something that SHOULD NOT BE DONE LIGHTLY. I don't know what your programming background is, but interface breaking changes require a lot of care. Interface breaking changes in one of the most obscure parts of the codebase, doubly so. If you want some advice, I can get you started, but changing this is not a priority. After everything that went into getting the upcoming update ready (no, I haven't heard from Unas) I want some time to work on my own case before I get back into the heavy-duty programming that would be needed to make this happen.
[D]isordered speech is not so much injury to the lips that give it forth, as to the disproportion and incoherence of things in themselves, so negligently expressed. ~ Ben Jonson
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

Re: [E][P] Inconsistent variable to variable less/greater comparisons

Post by TimeAxis »

Wasn’t intending to say anybody’s cases deserved to broken, sorry, more that I wasn’t convinced anybody’s case would be broken, in all likelihood. To give a hypothetical example of what I meant, if there were a typo in a relatively obscure and rarely used function (say there were a function for string length and it were spelled “string_legth”), my personal preference (and it’s nothing more, rest assured. Apologies if it came off otherwise.) would be to fix said typo rather than adding documentation explaining said typo, even on the off chance one or two people had built their case around said typo. It’s possible that an equal number of people built their cases spelling it the correct way, had no idea their cases were broken, and such an update would fix their cases rather than breaking them. (Granted, in this example, a solution that both fixes the typo and preserves the original typo’s function for compatibility wouldn’t be too hard, and it’s possible such a solution could exist in this situation as well.)

I had glanced at the expression engine code before this and noticed that “+” is the only operator that converts to integers, which was why I brought that change up. Making the others do so as well seemed a relatively trivial matter (albeit possibly with unintended side effects, as you rightly point out). If it’s not a priority, that’s no problem with me. If it would help, once I get more time, I can do some experimenting and lay out a full plan on how such a change would work (along with any side effects it may have) and make a suggestion thread for it. But if the priority is 100% guaranteed compatibility without even the slimmest possibility of anybody’s case needing to be updated, then it may not be worth it.
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
Post Reply