-
Notifications
You must be signed in to change notification settings - Fork 188
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
Document non-trivial function Code.constant_equal, and fix related bugs #1659
Conversation
See js_of_ocaml/compiler/lib/code.ml Lines 404 to 405 in 3204c33
Is it definitely the case that in Javascript |
An int64 is implemented as a JavaScript object, which is never equal to a JavaScript number. |
Also I think the fix in #1048 is wrong and we should not use |
I'm guessing you mean
|
@vouillon, can you explain what's wrong with using I think the way forward is to come up with regression tests showing how the current implementation is wrong. @OlivierNicole, do you want to look at this ? |
I can look at this, but so far i’m confused:
Testing in ocaml 5.2.0 yields
This equality is true in both ocaml 5.2.0 and Node (with |
We have this definition in let equal (a : float) (b : float) =
Int64.equal (Int64.bits_of_float a) (Int64.bits_of_float b) |
Yes, very! |
In On the other hand, we want that if It is possible to define a function that satisfies both constraints by special-casing |
Regarding this, I suggest we stop shadowing the IEEE754-complying stdlib |
I agree that we should rename this function. But |
After checking, the only other place it is used is in js_of_ocaml/compiler/lib/javascript.ml Lines 106 to 128 in 3204c33
I’m not entirely sure what it does, but I expect we can adapt it if needed. |
|
3ed6c34
to
90ab0c6
Compare
I have updated the comment, and attempted to fix the two compilation bugs that you have mentioned here. Edit: I renamed a file from |
I will also add regression tests |
1e3ae98
to
cd27c37
Compare
I have added a regression test. |
cd27c37
to
ade9bdb
Compare
ade9bdb
to
89f04f0
Compare
Maybe we should rename it |
If memory serves this is to make |
Thanks, I was indeed expecting equal to be the ieee one. |
Co-authored-by: Jérome Vouillon <[email protected]>
This reverts commit 94493de.
This reverts commit fece17d8bc601e7bb1717ecc04dedafa10bdb64f.
…related bugs (#1659) * Document non-trivial function Code.constant_equal Co-authored-by: Jérome Vouillon <[email protected]> * Fix bugs related to constant equality See #1659. * More static evaluation of equalities in eval * Statically evaluate caml_js_strict_equals too * Compiler: small refactoring in eval --------- Co-authored-by: Jérome Vouillon <[email protected]> Co-authored-by: Hugo Heuzard <[email protected]>
I think this will be useful to future us.
(@vouillon excavated the semantics of the function.)