Skip to content

TP0206

Error: cannot infer type of empty collection

  • cannot infer the type of '<f>', with help give it a type, e.g. 'let f: Callable[[…], …] = <f>' (a generic function, built-in or constructor as a value, M40)
  • cannot infer the type of an empty list
  • ... empty dict
  • cannot infer the type of None
  • cannot infer '<T>' for '<f>'
  • cannot infer the type of lambda parameter '<x>', with help add a type annotation

From the golden case tests/cases/m35/tp0206_set.tpn:

tp0206_set.tpn
# An empty set needs an expected type, as [] does (SPEC §3.15).
let s = set()

The compiler reports:

tp0206_set.tpn:2:9: error TP0206: cannot infer the type of an empty set
help: add a type annotation

The specification lists every code.