You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
jsoo's implementation of caml_float_of_string doesn't match Stdlib's handling of whitespace: jsoo allows trailing whitespace while regular ocaml does not
OCaml version 4.14.0
Enter #help;; for help.
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
# float_of_string "3.14";;
- : float = 3.14
# float_of_string " 3.14";;
- : float = 3.14
# float_of_string "3. 14";;
Exception: Failure "float_of_string".
# float_of_string "3.14 ";;
Exception: Failure "float_of_string".
(tl;dr float_of_string "3.14 " fails in regular ocaml but not jsoo)
Expected behavior
Trailing whitespace passed to float_of_string would raise an exception.
This PR does a bunch of things:
- Semgrep.js parsers:
- Factors out the test harness plumbing into `js/shared/parser.js`
- Updates parsers to use official pattern / parsing test fixtures, which
means more test coverage for jsoo
- Fixed a few parsers that didn't match their Parse_target2.ml /
Parse_pattern2.ml counterparts
- fixed issues with utf-8 in libpcre.js
- jsoo's caml_float_of_string doesn't handle whitespace the same way as
Stdlib (issue: ocsigen/js_of_ocaml#1518)
- testing:
- added `js/tests` which runs the entire Semgrep test suite against the
semgrep.js artifacts
- (with some tests currently disabled for various reasons, see:
https://github.com/returntocorp/semgrep/pull/8902/files#diff-dd182dfc008e74db2491c9b572d2f1885943808bf40dd7f2d384a097c6f86a96R26-R39)
- due to how semgrep.js parsers work, had to make jsonnet parser
initialization lazy (See:
https://github.com/returntocorp/semgrep/pull/8902/files#diff-2ca9fa192a8e7f7613f16ab4969198be90b75bd5fe38ed3f79a1d23fb59f1e59R57-R59)
- Updated Entropy.ml to explicitly use Int64 so that it still works on
32-bit systems (namely: browsers)
(^ @tpetr wrote this -- @ajbt200128 , feel free to update)
test plan:
- checks pass
---------
Co-authored-by: Tom Petr <tom@r2c.dev>
Describe the bug
jsoo's implementation of
caml_float_of_string
doesn't match Stdlib's handling of whitespace: jsoo allows trailing whitespace while regular ocaml does notjsoo toplevel:
ocaml toplevel:
(tl;dr
float_of_string "3.14 "
fails in regular ocaml but not jsoo)Expected behavior
Trailing whitespace passed to
float_of_string
would raise an exception.Versions
ocamlc 4.14
jsoo 5.4.0
(NOTE: this is an extremely low-priority bug, but wanted to flag it because we stumbled across it in semgrep.js: https://github.com/returntocorp/semgrep/pull/8902/files#diff-e2f964d2fdf546821a6fcd6c642efc8e962a8972a1731b8196d36ef2e0aa621dR44-R47)
The text was updated successfully, but these errors were encountered: