Repository navigation
Propagate physical comparison operators to lambda - #13588
Merged
Merged
Conversation
Contributor
Author
|
@OlivierNicole, do you still plan to review this PR ? |
Contributor
|
Sorry for the delay. As this depends on #13438 to be useful, we should probably decide on the fate of that one first. |
OlivierNicole
approved these changes
Mar 25, 2026
OlivierNicole
left a comment
Contributor
There was a problem hiding this comment.
Overall this looks good to me modulo a small renaming suggestion in Instruct. This set of changes has the nice side effect that we will stop compiling (==) to Pintcomp, which I’ve always found a bit confusing.
OlivierNicole
requested changes
Apr 2, 2026
Co-authored-by: Olivier Nicole <[email protected]>
Separate the physical equality bytecode instruction from integer comparison by introducing a dedicated Kphyscomp constructor, instead of encoding it as Kintcomp with a boolean flag. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
OlivierNicole
approved these changes
Apr 2, 2026
OlivierNicole
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Could you add a changelog entry?
Contributor
Author
done |
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
The two snippets below currently compile to the same bytecode
let f (a : int) b = a = blet g a b = a == bIn js_of_ocaml, I want to compile theses two differently. The reason is that the
===javascript operator doesn't match the behavior of the standard ocaml runtime.For details,
-0. === 0.returnstrueandNaN === NaNreturnsfalse. See ocsigen/js_of_ocaml#1372This PR
This PR prepares the code base for the actual fix by forwarding more information to lambda.
This would allow #13438 to emit more hints or we could decide to change bytegen later to emit different code.
The main change in this PR is the addition of a primitive in lambda
Pphyscomp of physical_comparisonand the following change in
translprim.ml