provo a compilare il seguente codice:campo sommerso nel tipo ereditato compilazione programma Nimrod
type
TPerson = object of TObject
name*: string
age: int
TStudent = object of TPerson
id: int
var
student: TStudent
person: TPerson
student = TStudent(name: "Anton", age: 5, id: 2)
ma ottengo il seguente errore:
Error: undeclared field: 'id'
Come è id
non dichiarato? L'esempio del codice è direttamente dal tutorial. È cambiato qualcosa nella lingua che non si riflette nel tutorial?
Inoltre, se provo a eseguire il codice seguente:
student = TStudent(name: "Anton")
echo student.name
ottengo il seguente errore:
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Perché?
Trovato qualcuno con lo stesso problema nei [forum di nimrod] (http://forum.nimrod-code.org/t/285) – sloth