Skip to content

TP0211

Error: function references a top-level variable

  • '<f>' cannot use top-level variable '<x>', with help pass it as a parameter, or make it a const

From the golden case tests/cases/m14/tp0211_defaults.tpn:

tp0211_defaults.tpn
let limit = 10
def f(n: int = limit) -> int:
return n
print(f())

The compiler reports:

tp0211_defaults.tpn:3:16: error TP0211: 'f' cannot use top-level variable 'limit'
help: pass it as a parameter, or make it a const

The specification lists every code.