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 js ouput of bigint max, min #7088

Merged
merged 4 commits into from
Oct 7, 2024
Merged

Fix js ouput of bigint max, min #7088

merged 4 commits into from
Oct 7, 2024

Conversation

mununki
Copy link
Member

@mununki mununki commented Oct 7, 2024

This PR fixes the issue where max, min operations generate js ouput incorrectly. It is described in the related issue #7062 (comment)

@mununki
Copy link
Member Author

mununki commented Oct 7, 2024

Since there were no tests for max and min, it seems we were unable to identify issues during testing. Therefore, I have added the necessary tests.

@mununki mununki requested a review from cometkim October 7, 2024 02:18
@@ -416,7 +416,7 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
| _ -> assert false)
| Pbigintmax -> (
match args with
| [ { expression_desc = Number (Float _) } as a; { expression_desc = Number (Float _) } as b ]
| [ { expression_desc = Number (BigInt _) } as a; { expression_desc = Number (BigInt _) } as b ]
when Js_analyzer.is_okay_to_duplicate a && Js_analyzer.is_okay_to_duplicate b ->
E.econd (E.js_comp Cgt a b) a b
Copy link
Member

Choose a reason for hiding this comment

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

Use E.bigint_comp here should improve the outputs

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, thanks. 77a4630

Copy link
Member

Choose a reason for hiding this comment

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

Hmm ok E.econd itself doesn't seem to be optimized enough yet

@mununki mununki merged commit 403f11d into master Oct 7, 2024
20 checks passed
@mununki mununki deleted the fix-bigint-max-min branch October 7, 2024 03:58
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.

2 participants