Fix issue when using custom setter

The problem was that the generated value was not added to the internal list
of variables. Therefore references to the variable were broken.