miniblog.

← Back to all posts
13
What types should you infer when code is invalid? In Garden, + only applies to integers. What should the type of "x" + "y" be? (1) Int: This produces cascading errors. (2) String: We've already emitted an error anyway. (3) Bottom. Opinions?

3 Comments

@wilfredh The type that will make the parent expression type check in most cases. So (3) in your system. (it'd be a fresh unification variable in my system)
@wilfredh 3 always
@wilfredh It might be a good idea to add a special "type error" type that can only be created by the compiler/interpreter if it encounters a type error, an unknown type name or something similar. This would make it easy to ignore follow up errors by silently poisoning any calculations with values of type "type error".