Skip to content

fix: key the persistent code cache on the language level - #57

Merged
marevol merged 1 commit into
es6/fix-compiler-test-globalfrom
es6/fix-code-cache-language
Aug 28, 2026
Merged

fix: key the persistent code cache on the language level#57
marevol merged 1 commit into
es6/fix-compiler-test-globalfrom
es6/fix-code-cache-language

Conversation

@marevol

@marevol marevol commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Stacked on #56.

A script compiled under --language=es6 was served back to an --language=es5 run, which then executed syntax es5 cannot parse:

// over the 1000 character store threshold
var f = (a) => a * 3;
print("arrow result: " + f(1));
command output
sai --language=es6 --persistent-code-cache big.js arrow result: 3
sai --language=es5 --persistent-code-cache big.js arrow result: 3
sai --language=es5 big.js SyntaxError: Expected ; but found =>

The store directory is named after a digest of the sai jar, with _opt appended for optimistic types. The language level appeared nowhere in it, and Context.compile consults the store before the source is parsed, so the entry was found and the parser never ran.

The same hole exists for -scripting and --no-syntax-extensions and predates this series, but --language is the axis the series turns on: es5 behaviour being unchanged is the whole guarantee, and this broke it. So _es6 now goes into the directory name beside _opt.

getCodeCachePath in the test grew the same distinction, or it could have handed an es6 directory to a test asking for the es5 one.

Verification

./gradlew build testOptimistic testPessimistic

suite before after
test 665, 0 fail 666, 0 fail
testOptimistic 1717, 0 fail 1718, 0 fail
testPessimistic 1717, 0 fail 1718, 0 fail

A script compiled under --language=es6 was served back to an --language=es5 run,
which then executed syntax es5 cannot parse:

    // over the 1000 character store threshold
    var f = (a) => a * 3;
    print("arrow result: " + f(1));

    sai --language=es6 --persistent-code-cache big.js   arrow result: 3
    sai --language=es5 --persistent-code-cache big.js   arrow result: 3
    sai --language=es5                        big.js    SyntaxError: Expected ; but found =>

The store directory is named after a digest of the sai jar, with "_opt" appended
for optimistic types. The language level appeared nowhere in it, and
Context.compile consults the store before the source is parsed, so the entry was
found and the parser never ran.

The same hole exists for -scripting and --no-syntax-extensions and predates this
series, but --language is the axis the series turns on: es5 behaviour being
unchanged is the whole guarantee, and this broke it. So "_es6" now goes into the
directory name beside "_opt".

getCodeCachePath in the test grew the same distinction, or it could have handed
an es6 directory to a test asking for the es5 one.

./gradlew build testOptimistic testPessimistic:

  suite            before         after
  test             665, 0 fail    666, 0 fail
  testOptimistic   1717, 0 fail   1718, 0 fail
  testPessimistic  1717, 0 fail   1718, 0 fail
@marevol
marevol force-pushed the es6/fix-code-cache-language branch from 35e6a8f to e7b91da Compare August 28, 2026 05:11
@marevol marevol self-assigned this Aug 28, 2026
@marevol
marevol merged commit 8a6b50a into master Aug 28, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant