I try to compile the following code:
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)
but I get the following error:
Error: undeclared field: 'id'
How is id
not declared? The code sample is straight from the tutorial. Did something in the language change that is not reflected in the tutorial?
Also, if I try to run the following code:
student = TStudent(name: "Anton")
echo student.name
I get the following error:
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Why?