View Issue Details

IDProjectCategoryView StatusLast Update
0006026The Dark ModCodingpublic28.07.2022 18:31
Reporterstgatilov Assigned Tostgatilov  
Status resolvedResolutionfixed 
Product VersionTDM 2.10 
Target VersionTDM 2.11Fixed in VersionTDM 2.11 
Summary0006026: Wrong order of evaluation in expressions
Description Here are a few weird facts about order of evaluation in expressions, true both in materials and in GUI scripts:

1) Same-priority operations are evaluated in right-to-left order. So a-b+c is computed as a-b-c and vice versa.
2) Logical OR and AND are same-priority operations, and are thus evaluated in left-to-right right-to-left order.
3) Comparisons <=, >=, <, > have same priority as == and !=: that's not a big deal, but differs from C/C++ rules.

I'd like to fix it and change to exact C/C++ rules.
Additional InformationOriginally reported here:
TagsNo tags attached.


related to 0005852 resolvedstgatilov Refactor objectives GUI and fix checkboxes in restart GUI 
related to 0005869 resolvedstgatilov Better diagnostic for syntax errors in GUI code 




28.07.2022 18:31

administrator   ~0015085

Done in commits:
  r10043 Execute same-priority operations in left-to-right order instead of right-to-left (GUI and materials).
  r10044 Adjusted operator precedence like in C/C++.
  r10045 Fixing ternary operator in GUI scripting.
  r10046 Removed code for issuing warnings in the cases wth changed behavior.
  r16576 Fixed evaluation order in two cases where buggy engine behavior makes it different from what's mathematically correct.

Note that intermediate revisions contains some code to detect problematic cases and issue warning.
But I have detected too few such cases in core assets, so I think it's not worth leaving this code.

Issue History

Date Modified Username Field Change
27.07.2022 20:46 stgatilov New Issue
27.07.2022 20:46 stgatilov Status new => assigned
27.07.2022 20:46 stgatilov Assigned To => stgatilov
27.07.2022 20:46 stgatilov Relationship added related to 0005852
27.07.2022 20:46 stgatilov Relationship added related to 0005869
27.07.2022 20:47 stgatilov Summary Wrong order => Wrong order of e
27.07.2022 20:47 stgatilov Summary Wrong order of e => Wrong order of evaluation in expressions
28.07.2022 18:31 stgatilov Note Added: 0015085
28.07.2022 18:31 stgatilov Status assigned => resolved
28.07.2022 18:31 stgatilov Resolution open => fixed
28.07.2022 18:31 stgatilov Fixed in Version => TDM 2.11