Skip to content

TP0214

Error: duplicate definition

  • duplicate definition of '<x>'
  • key <k> appears twice in a mapping pattern (M38)

From the golden case tests/cases/m15/tp0214_classes.tpn:

tp0214_classes.tpn
# Member names must be distinct, inherited ones included (SPEC §4.3, §4.6).
class Base:
name: str = ""
def run(self):
pass
class Sub(Base):
name: str = "x"
run: int = 0

The compiler reports:

tp0214_classes.tpn:9:5: error TP0214: duplicate definition of 'name'
tp0214_classes.tpn:10:5: error TP0214: duplicate definition of 'run'

The specification lists every code.