Fix type inference problem with overloaded functions

Fixes #496.