Skip to content
scrambled
Programming Language Theory Flashcard

Why does type inference cause vague error messages?

Books Concepts Deckcompiler implementation

Question

Why does type inference cause vague error messages?

Answer

Sometimes, multiple types are inferred for a variable at different locations. The question: Which type and which location to report?

Example:

f x=if x then x+1 else 2
  • x can be a boolean, if so, must report error at x+1 in the then branch .

  • x can be a number, if so, must report error at x in the condition.