A best-effort type is a sensible approximation returned when an expression has no obviously correct type. It keeps type computation running while a type-checking constraint reports the error. section 13.1 section 13.4
Compute it as though a minimal modification made the expression meaningful, often by effectively ignoring one operand’s type. If no sensible approximation exists, return the special untype value. section 13.1 section 13.4
Typical binary-operation rules include:
- Treat subtraction as the left numeric type when the left operand is amount or percentage. section 13.1
- When subtraction has an untyped left operand and a numeric right operand, use the right operand’s type. section 13.1
- Treat an “of” expression with an amount-typed right operand as amount; otherwise return untype. section 13.1
- Mark a best-effort result for an error while leaving impossible combinations as x until no approximation exists. section 13.1
Rental price expression
For an amount-typed right operand, “<left operand> of <amount-typed right operand>” can produce amount even when the left operand is invalid. The type checker still reports an error on that expression. section 13.1
