Skip to content

"Expected: :" error in ExtendScript #1144

Closed
@fusepilot

Description

@fusepilot

I'm trying to use Uglify to compress and obscure Adobe ExtendScript ( ES3 dialect of JS ) code. Uglify seems to strip parentheses in nested ternary expressions. ExtendScript can't understand this and throws an error: Expected: :.

Input code:

// input.js

function toInteger(value) {
  var result = parseFloat(value);
  var remainder = result % 1;

  return result === result ? (remainder ? result - remainder : result) : 0;
}

toInteger(2.1); // Result: 2

Output code from uglifyjs -b -c -o output.js -- input.js:

// output.js

function toInteger(value) {
    var result = parseFloat(value), remainder = result % 1;
    return result === result ? remainder ? result - remainder : result : 0; // Error: Expected: :
}

toInteger(2.1);

I'm aware how edge case this is, but it would be great if there was a compression option to keep the parentheses in for this scenario.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions