TP0222
Error: top-level statement in an imported module, or in a library’s main file (M22) or an extension module (M25)
Messages
Section titled “Messages”only the main file can have top-level statementsa library can't have top-level statements(M22)a Python extension can't have top-level statements(M25)
Example
Section titled “Example”From the golden case tests/cases/m45/tp0222_native_library.tpn:
# A native library has no top level (SPEC §15.6).print("hello")
def f() -> int: return 1The compiler reports:
tp0222_native_library.tpn:2:1: error TP0222: a native library can't have top-level statementsThe specification lists every code.
© 2026 Discover Edge, LLC · Taipan is released under the MIT License.