# strange but this work as expected: type Sample = ptr SampleObj SampleObj = object procedure: proc() let someType = cast[Sample](allocShared0(sizeof(SampleObj))) echo someType.procedure == nil, " step 1" someType.procedure = proc() = echo "Call procedure" echo someType.procedure == nil, " step 2" someType.procedure() deallocShared(someType) echo someType.procedure == nil