Skip to main content
YuK1_Works
Inspiring
July 24, 2025

Bug in ExtendScript’s Conditional (Ternary) Operator

  • July 24, 2025
  • 4 replies
  • 252 views

 

ExtendScript’s conditional operator resolves expressions in the wrong order. In the case of:

true ? a : true ? b : c;

I would expect it to return a, but ExtendScript actually returns b. This behavior is a major source of latent bugs in scripts. It urgently needs to be fixed.

 

I first noticed this when injecting polyfills into legacy ExtendScript. Common minification plugins like terser convert if statements into ternary expressions. To avoid relying on polyfills, Adobe should either update ExtendScript to support at least ES2015 or fix this egregious bug.

4 replies

YuK1_Works
Inspiring
July 24, 2025

Sorry, I lost my cool there.
You're right—adding parentheses like that does make it work as expected.
However, many formatters and minify tools tend to remove such “unnecessary” parentheses.

July 24, 2025

I'm just asking if adding the parens solves the order of operations that you're seeing? If it does, perhaps the minify tool could do that for you. I don't expect there will be a fix in a shortish timeframe, so just trying to help with a workaround. 

YuK1_Works
Inspiring
July 24, 2025

You're saying I should manually add parentheses after minifying?

July 24, 2025

If you use parens, does it help? e.g.

true ? a : (true ? b : c)