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 overflow issues occurs when *unchecked-math* is disabled #337

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alumi
Copy link
Member

@alumi alumi commented Mar 24, 2025

fixes: #332

This PR fixes issues found in #330 (review)

Some functions under cljam.io.cram and cljam.io.util.lsb used the checked narrowing conversions of numerical values (byte, int, ...) or implicit conversions with typed method callings of Java core library.
These narrowing of numeric types works fine as long as *unchecked-math* is set to true or only non-negative integers are involved. However, if *unchecked-math* is false (which is the default) and a negative integer is provided, an exception is thrown.
In this PR, I have explicitly applied unchecked narrowing (unchecked-byte, unchecked-int, ...) to bypass range checks and ensure the intended output.
I have also fixed the :gloval-vars option in the project to reset the compiler options while testing in CI.

I have confirmed that lein test :all passes.

@alumi alumi added the bug label Mar 24, 2025
@alumi alumi requested a review from a team as a code owner March 24, 2025 03:31
@alumi alumi requested review from athos and ToshimitsuArai and removed request for a team and ToshimitsuArai March 24, 2025 03:31
@alumi alumi changed the title Fix overflow issues occurs when *unchecked-math* is true Fix overflow issues occurs when *unchecked-math* is disabled Mar 24, 2025
Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.95%. Comparing base (9408e13) to head (1e69b95).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #337      +/-   ##
==========================================
- Coverage   89.96%   89.95%   -0.01%     
==========================================
  Files         104      104              
  Lines        9723     9719       -4     
  Branches      529      529              
==========================================
- Hits         8747     8743       -4     
  Misses        447      447              
  Partials      529      529              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

Overflow issues that occur when *unchecked-math* is disabled
2 participants