pufuwozu/roy — pull request #111 by taku0 (2012-02-21 14:10:32+00:00)
Title: Fixed type inference of pattern variable

### Problem
Failed to infer types of variables in deep pattern matches.

### Sample Code

data XX = X
data YY = Y XX
let yy = Y X
let idXX (x:XX) = x
match yy
case (Y x) = idXX x

### Expected
Compiled without error.

### Actual

Type error: YY is not XX

### Cause

in addVarsToEnv:

newEnv[v.value] = currentValue;

newEnv[v.value] should be the type of the variable but currentValue is the type of the pattern.
data[p.tag.value][i] is the expected type from data constructor.

### Fix
Assign data[p.tag.value][i] instead of currentValue to newEnv[v.value].