pufuwozu/roy — Issue #86: Disallow identically named variables introduced in pattern match
Author: eegg
Created: 2011-12-15 23:19:42+00:00
State: open

The Roy code

```haskell
data Maybe a = Nothing | Just a
data Tree a = Nil | Tree (Tree a) a (Tree a)
let rootValue t = match t
case Nil = Nothing
case (Tree v v v) = Just v
```

compiles (0.1.3) to

```javascript
var Nothing = function(){};
var Just = function(a){this._0 = a};
var Nil = function(){};
var Tree = function(Tree, a, Tree){this._0 = Tree;this._1 = a;this._2 = Tree};
var rootValue = function(t) {
return (function() {
if(t instanceof Nil) {
return new Nothing();
} else if(t instanceof Tree) {
var v = t._0;
var v = t._1;
var v = t._2;
return new Just(v);
}
})();
}
```

where it should issue a compiler error, e.g. `Repeated variable "v" in pattern`.