Skip to content

Fix switch statement issue#97

Merged
martin-henz merged 2 commits into
mainfrom
switch
Jun 24, 2026
Merged

Fix switch statement issue#97
martin-henz merged 2 commits into
mainfrom
switch

Conversation

@kjw142857

Copy link
Copy Markdown
Contributor

Fixes #93

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the switch statement code generation in src/compiler/code-generator.ts by reserving 4-byte placeholders for branch targets and patching them later with full 4-byte signed big-endian offsets. A critical issue was identified in the non-table switch (LOOKUPSWITCH) patching logic, where using caseLabels[k] to retrieve the target label can lead to index misalignment and incorrect branch targets or out-of-bounds errors. It is recommended to use caseLabelMap to look up the correct label for each case value instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/compiler/code-generator.ts
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.27% (-0.23% 🔻)
7408/10251
🔴 Branches
59.12% (-0.06% 🔻)
2480/4195
🟡 Functions 69.04% 1320/1912
🟡 Lines
73.13% (-0.25% 🔻)
6974/9537
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / code-generator.ts
65.66% (-2.6% 🔻)
60.38% (-0.66% 🔻)
65.43%
66.47% (-2.64% 🔻)

Test suite run success

1134 tests passing in 64 suites.

Report generated by 🧪jest coverage report action from be416fd

@kjw142857
kjw142857 requested a review from martin-henz June 24, 2026 01:14
@kjw142857 kjw142857 self-assigned this Jun 24, 2026

@martin-henz martin-henz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@martin-henz
martin-henz merged commit 8ecede1 into main Jun 24, 2026
4 checks passed
@martin-henz
martin-henz deleted the switch branch June 24, 2026 02:54
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.

Fix switching logic for JVM

2 participants