Git Product home page Git Product logo

ocamljs's People

Contributors

duckpilot avatar ramen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ocamljs's Issues

Compiler crashes when setter/getter is called

The following code crashes the ocamljs compiler:

let f o = o#_get_x 1

it says:

Fatal error: exception Failure("bad method call")

while the following equivalent code compiles without crash:

let f o = let g = o#_get_x in g 1

It seems that the getter must not be applied directly to any argument, or ocamljs will die.
Although it is not fatal since there's workaround, it might be better if a more informative message is provided.

Similarly, the following code, which misses the setter's argument, will crash:

let f o = o#_set_x

The error message is the same:
Fatal error: exception Failure("bad method call")

max_int, min_int and min_float do not have the correct values

Pervasives.max_int and min_int have the following incorrect value, respectively: 1073741823 and 1073741824.
They are apparently not maximum or minimum integer in the JavaScript.
Though this might not be a bug in ocamljs.

The root cause is the definition in the stdlib/pervasives.ml in the OCaml distribution:

let min_int = 1 lsl (if 1 lsl 31 = 0 then 30 else 62)
let max_int = min_int - 1

which, if directly compiled into JS by ocamljs, will turn into a wrong value.

(For the meantime, I'm using this command to replace them with the correct value:
cat target-tmp.js |
gsed -E -e 's/var (min_int$$[0-9]+)./var \1 = -Math.pow(2,53);/g'
-e 's/var (max_int$$[0-9]+).
/var \1 = Math.pow(2,53);/g' > target.js
(This is in my Makefile so the each occurrence of dollar ($) sign is doubled)

Similarly, min_float is 0. because it is defined as

let min_float =
  float_of_bits 0x00_10_00_00_00_00_00_00L

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.