PAC-K020 · es2018-syntax

JavaScript syntax newer than ES2017 (?., ??, object spread)

high · Compatibility across engines

Windows fails to load a PAC file that contains syntax newer than ES2017, such as ?., ??, object spread {...o}, BigInt literals or newer regular-expression forms. Every Windows program then ignores the file, while Chrome and Firefox run it without a complaint.

Why it matters

ES2017 is the 2017 edition of the JavaScript standard; each yearly edition adds new syntax. Chrome and Firefox understand all of it. Windows does not: in the lab on Windows 11 (2026-10-11), optional chaining (a?.b), the ?? operator, object spread ({...o}), BigInt literals (10n) and the regular-expression forms lookbehind ((?<=a)) and named groups ((?<name>...)) were syntax errors. A syntax error stops the whole file from loading, so every Windows program that leaves the file to Windows (system services, programs that use WinHTTP or WinINet, .NET and Java programs) behaves as if there were no PAC file at all. The same file works in a browser test, which is why the problem is easy to miss.

The rule also reports constructs that are newer still than the ones measured: the ??=, ||= and &&= operators, the regular-expression flags s, d and v, for await, async generators, catch without a parameter, and class fields. Syntax from ES2015 to ES2017 (let, const, arrow functions, template strings) works on Windows; older engines that fail on it are covered by ES2015 to ES2017 syntax.

A file that does not load on the most common desktop platform is not a style issue, so the finding caps the grade at D.

How to fix

Write the code out in ES5, for example (a && a.b) instead of a?.b, (a != null ? a : b) instead of a ?? b, and a plain loop or a list of properties instead of {...o}.

Examples

Bad

var proxies = ["PROXY proxy.corp.example:8080"];
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
  return proxies?.[0] ?? "DIRECT";
}
Open bad example in checker

Good

var proxies = ["PROXY proxy.corp.example:8080"];
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
  return proxies && proxies[0] != null ? proxies[0] : "DIRECT";
}
Open good example in checker

Engine behaviour

EngineBehaviourSource
chromiumV8; current ECMAScript syntax parses.code, verified 2026-10-04 · ref
firefoxSpiderMonkey; current ECMAScript syntax parses (no language restriction for PAC scripts).code, verified 2026-10-04 · ref
winhttpOptional chaining (?.), ??, object spread, BigInt literals, regular-expression lookbehind and named groups are syntax errors, and then the whole file fails to load. ES2015 to ES2017 syntax (let, const, arrow functions, classes, template strings, array spread, async functions, generators, **) works.lab, verified 2026-10-11
wininetSame script engine as Windows (WinHTTP); the same syntax fails to load.lab, verified 2026-10-11

Source: code = read in the engine's source, doc = vendor documentation, lab = observed in a lab run, expert = practitioner knowledge, not yet verified.

Related rules

References