Skip to content

TP0205

Error: condition must be bool

  • condition must be bool, found <T> (with help convert it with 'as bool' for py)

From the golden case tests/cases/m36/tp0205_comprehension.tpn:

tp0205_comprehension.tpn
# A comprehension's condition is a bool (SPEC §3.16).
let xs = [1, 0, 2]
print([x for x in xs if x])

The compiler reports:

tp0205_comprehension.tpn:3:25: error TP0205: condition must be bool, found int

The specification lists every code.