Fixed the way a match expression infers its type. Closes #543