Type of match expression is now correctly inferred. Closes #543