Skip to content

TP0226

Error: object used before it is fully initialized

  • '__init__' does not set '<f>'
  • '<f>' has no default, and '<C>' has no '__init__'
  • '<f>' is read before it is set
  • 'self' is used before '<f>' is set (or before 'super().__init__' is called)
  • '<f>' is inherited, so it is set by 'super().__init__'
  • 'super().__init__' is called before '<f>' is set
  • '<C>.__init__' must call 'super().__init__(…)'
  • 'super().__init__' must be called once, directly in '__init__'
  • 'super().__init__' can only be called in '__init__'
  • '__init__' returns before '<f>' is set (or before 'super().__init__' is called) (when several fields are unset, the first in declaration order is named)
  • 'super().__init__' must come first, since '<B>' is a .NET class (M43)

From the golden case tests/cases/m43/tp0226_dotnet.tpn:

tp0226_dotnet.tpn
# A .NET base is constructed first (SPEC §13.16).
from dotnet.System import Random
class Loaded(Random):
seed: int
def __init__(self, seed: int):
self.seed = seed
super().__init__(seed)

The compiler reports:

tp0226_dotnet.tpn:9:9: error TP0226: 'super().__init__' must come first, since 'Random' is a .NET class

The specification lists every code.