Register ScalarConstant as Scalar.Constant

This solves a problem uncovered by the previous commit: a variable with
an ndim field could be replaced by a Variable without one.