numba/numba — pull request #406 by laserson (2014-03-11 02:28:26+00:00)
Title: TypeVar.lock should check whether it's already locked

I discovered this problem when I was trying to implement this function
```python
@udf(IntVal(FunctionContext, IntVal))
def test_impala_1(context, a):
return None
```

During type inference, `infer.seed_return(IntVal)` locks the `TypeVar` to `IntVal`, which is good.
However, when `infer.build_constrain()` is executed, it will see that the associated block should
return a `none` type, and will lock it as `none` instead. This seems like it is a bug, because now
we've lost the explicit return type information.

By having `.lock()` check if the `TypeVar` has already been locked, it simply checks whether the new
lock candidate is compatible with the first one, and if so, it should call the appropriate cast down
the line.