Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minifier: incorrect minification in try_fold_left_child_op #7944

Closed
Boshen opened this issue Dec 16, 2024 · 2 comments · Fixed by #7949
Closed

minifier: incorrect minification in try_fold_left_child_op #7944

Boshen opened this issue Dec 16, 2024 · 2 comments · Fixed by #7949
Assignees
Labels
C-bug Category - Bug

Comments

@Boshen
Copy link
Member

Boshen commented Dec 16, 2024

((x - 1) & 1); -> x & 1;
((y >> 3) & 7); -> y & 3;

Reference:

https://github.com/google/closure-compiler/blob/ffa350b86aa68a8b3cf3b9e294c92f6b9f0831a3/src/com/google/javascript/jscomp/PeepholeFoldConstants.java#L1036

This was caught by monitor-oxc with luck .. took me a bit of time to track down.

https://github.com/oxc-project/monitor-oxc/actions/runs/12355173391/job/34478272871

/home/runner/work/monitor-oxc/monitor-oxc/node_modules/.pnpm/[email protected]/node_modules/brotli/build/encode.js:35
		if (!(a instanceof y)) throw a;
		                       ^

Error: [ReadHuffmanCode] invalid num_codes or space
    at ReadHuffmanCode (/home/runner/work/monitor-oxc/monitor-oxc/node_modules/.pnpm/[email protected]/node_modules/brotli/dec/decode.js:2[21](https://github.com/oxc-project/monitor-oxc/actions/runs/12355173391/job/34478272871#step:8:22):48)
    at BrotliDecompress (/home/runner/work/monitor-oxc/monitor-oxc/node_modules/.pnpm/[email protected]/node_modules/brotli/dec/decode.js:417:104)
    at BrotliDecompressBuffer (/home/runner/work/monitor-oxc/monitor-oxc/node_modules/.pnpm/[email protected]/node_modules/brotli/dec/decode.js:351:2)
    at Object.b.readBinary (/home/runner/work/monitor-oxc/monitor-oxc/node_modules/.pnpm/[email protected]/node_modules/brotli/build/encode.js:4:9)
    at Object.<anonymous> (/home/runner/work/monitor-oxc/monitor-oxc/node_modules/.pnpm/[email protected]/node_modules/brotli/build/encode.js:27329:13)

The bigger problem for me is how to systemically detect these kind of regressions 😭

@sapphi-red
Copy link
Contributor

sapphi-red commented Dec 17, 2024

The bigger problem for me is how to systemically detect these kind of regressions 😭

I can only think of running a property based testing like uglify js does. 😢
mishoo/UglifyJS#5963

@Boshen
Copy link
Member Author

Boshen commented Dec 17, 2024

The bigger problem for me is how to systemically detect these kind of regressions 😭

I can only think of running a property based testing like uglify js does. 😢 mishoo/UglifyJS#5963

Added to oxc-project/backlog#147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category - Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants