Closed taku0 closed 12 years ago
The following code should raise type error but not.
if 1 + 1 then 1 else 1
We must infer the type and unify it with Boolean type.
The following code
let x = true if true then let x = 2 1 else 1 console.log(x + 1)
which is compiled into
var x = true; (function() { if(true) { var x = 2; return 1; } else { return 1; } })(); console.log((x + 1));
should raise type error, but not.
If expressions are compiled into function, so that they introduce new environments. Thus, we must also introduce new environments in the type inferer.
let identityMonad = { return: \x -> x bind: \m f -> f m } do identityMonad let x = 1 let y = 1 z <- 1 return 1
is compiled into
... var __monad__ = identityMonad; var x = 1 var y = 1return __monad__.bind(1, function(z) { return __monad__.return(1); }); ...
\n is missing after “var y = 1”.
Problem 1: Conditions of if expressions are not type checked.
The following code should raise type error but not.
We must infer the type and unify it with Boolean type.
Problem 2: If expressions does not introduce new environment.
The following code
which is compiled into
should raise type error, but not.
If expressions are compiled into function, so that they introduce new environments. Thus, we must also introduce new environments in the type inferer.
Problem 3: Missing \n after inits of do expression
The following code
is compiled into
\n is missing after “var y = 1”.