pufuwozu/roy — pull request #133 by taku0 (2012-04-29 12:58:53+00:00)
Title: Fix minor bugs on statements

### Problem 1: Conditions of if expressions are not type checked.

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.

### Problem 2: If expressions does not introduce new environment.

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.

### Problem 3: Missing \n after inits of do expression

The following code

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”.