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

fix(es/parser, es/codegen): Handle trailing empty slots in array patterns #9992

Merged
merged 4 commits into from
Feb 6, 2025

Conversation

magic-akari
Copy link
Member

Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: 8701c60

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@magic-akari magic-akari changed the title fix(es/parser, es/codegen): Handle trailing empty slots in array patt… fix(es/parser, es/codegen): Handle trailing empty slots in array patterns Feb 5, 2025
@magic-akari
Copy link
Member Author

failures:

---- identity____swc_ecma_parser__tests__test262_parser__pass__5e7ca8611aaa4d53_js stdout ----
Input: /home/runner/work/swc/swc/crates/swc_ecma_parser/tests/test262-parser/pass/5e7ca8611aaa4d53.js


========== Running codegen test 5e7ca8611aaa4d53.js
Source:
let [a,,]=1


Pos: BytePos(1) ~ BytePos(13) (L1)
Expected code:
let[a,,]=1;
---- Actual -----
Token: 0:4 => 0:3
Token: 0:9 => 0:8
---- Expected -----
Token: 0:7 => 0:6
[crates/swc_ecma_codegen/tests/sourcemap.rs:393:9] &src_map = Vec(
    [
        (
            BytePos(
                1,
            ),
            LineCol {
                line: 0,
                col: 0,
            },
        ),
        (
            BytePos(
                5,
            ),
            LineCol {
                line: 0,
                col: 3,
            },
        ),
        (
            BytePos(
                6,
            ),
            LineCol {
                line: 0,
                col: 4,
            },
        ),
        (
            BytePos(
                10,
            ),
            LineCol {
                line: 0,
                col: 8,
            },
        ),
        (
            BytePos(
                11,
            ),
            LineCol {
                line: 0,
                col: 9,
            },
        ),
    ],
)
----- Visualizer -----
Expected: https://evanw.github.io/source-map-visualization/#MTEAbGV0W2EsLF09MTsxMzAAeyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXQuanMiLCJzb3VyY2VzIjpbIjAiXSwic291cmNlc0NvbnRlbnQiOlsibGV0IFthLCxdPTFcbiJdLCJuYW1lcyI6WyJhIl0sIm1hcHBpbmdzIjoiQUFBQSxJQUFLQSxFQUFFLEdBQUcifQ==
Actual: https://evanw.github.io/source-map-visualization/#MTEAbGV0W2EsLF09MTsyMDYAeyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9ob21lL3J1bm5lci93b3JrL3N3Yy9zd2MvY3JhdGVzL3N3Y19lY21hX3BhcnNlci90ZXN0cy90ZXN0MjYyLXBhcnNlci9wYXNzLzVlN2NhODYxMWFhYTRkNTMuanMiXSwic291cmNlc0NvbnRlbnQiOlsibGV0IFthLCxdPTFcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxHQUFJLENBQUMsSUFBSSxDQUFDIn0=
thread 'identity____swc_ecma_parser__tests__test262_parser__pass__5e7ca8611aaa4d53_js' panicked at crates/swc_ecma_codegen/tests/sourcemap.rs:479:9:
assertion `left == right` failed: col mismatch at 0:6
  left: 7
 right: 5

I'm not very familiar with sourcemap, do you know how to fix it? @kdy1

@kdy1
Copy link
Member

kdy1 commented Feb 5, 2025

Can you add an entry to https://github.com/magic-akari/swc/blob/38801dddf4ef2e583f8622ec09a13178a3eefa48/crates/swc_ecma_codegen/tests/sourcemap.rs#L13 for now?

Fixing source map issue would take some time, so I think it's better to ignore it for a fix for correctness patches about logic.

@magic-akari magic-akari marked this pull request as ready for review February 5, 2025 08:47
@magic-akari magic-akari requested a review from a team as a code owner February 5, 2025 08:47
Copy link

codspeed-hq bot commented Feb 5, 2025

CodSpeed Performance Report

Merging #9992 will degrade performances by 3.35%

Comparing magic-akari:fix/issue-9921 (8701c60) with main (afe21b5)

Summary

⚡ 1 improvements
❌ 1 regressions
✅ 194 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
es/full/minify/libraries/jquery 195 ms 201.7 ms -3.35%
es/full/minify/libraries/moment 128 ms 120.7 ms +6%

@kdy1 kdy1 added this to the Planned milestone Feb 6, 2025
@kdy1 kdy1 requested a review from a team as a code owner February 6, 2025 02:09
@kdy1 kdy1 enabled auto-merge (squash) February 6, 2025 02:11
@kdy1 kdy1 merged commit 1a87e76 into swc-project:main Feb 6, 2025
170 checks passed
@kdy1 kdy1 modified the milestones: Planned, v1.10.15 Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

minifier: incorrectly remove comma in ArrayAssignmentPattern of Destructing Assignment
2 participants