-
Notifications
You must be signed in to change notification settings - Fork 474
Closed
Labels
Description
Consider the following program:
$ cat issues-bs/syntax3.ml
(let _s = (let h = true in fun x -> let j = fun f -> true in fun f -> 0) "" "" in 0)
It is vanilla OCaml which can be compiled and run with the bytecode compiler:
$ ocamlc -o issues-bs/syntax3.byte issues-bs/syntax3.ml
File "issues-bs/syntax3.ml", line 1, characters 15-16:
Warning 26: unused variable h.
File "issues-bs/syntax3.ml", line 1, characters 40-41:
Warning 26: unused variable j.
$ ./issues-bs/syntax3.byte
$
However BuckleScript compiles it into what my node installation (and SpiderMonkey) considers syntactically incorrect JavaScript:
$ ./node_modules/bs-platform/bin/bsc.exe issues-bs/syntax3.ml
File "issues-bs/syntax3.ml", line 1, characters 15-16:
Warning 26: unused variable h.
File "issues-bs/syntax3.ml", line 1, characters 40-41:
Warning 26: unused variable j.
$ cat issues-bs/syntax3.js
// Generated by BUCKLESCRIPT VERSION 1.7.4, PLEASE EDIT WITH CARE
'use strict';
function () {
return function () {
return 0;
};
}("")("");
/* Not a pure module */
$ node issues-bs/syntax3.js
/the/path/to/the/dir/issues-bs/syntax3.js:5
function () {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
$ js17 issues-bs/syntax3.js
issues-bs/syntax3.js:5:0 SyntaxError: function statement requires a name:
issues-bs/syntax3.js:5:0 function () {
issues-bs/syntax3.js:5:0 .........^
This is with BuckleScript 1.7.4 (Using OCaml4.02.3+BS ) and node v6.10.3.