In the class CelestialBody radius, name and mass are examples of fields/variables. Every object of the type CelestialBody has its own instances of these fields. Changing the mass field in one object will not affect the mass in another object.
Duplicate field names is not allowed in class declarations. The name of a declared element must be different from the names of all other declared elements in the class.
Only the syntax is Ok, but not the semantics, i.e., typing and declarations have not yet been checked.
As we can see when simulating IllegalDuplicate, the class generates an error for trying to redefine the field duplicate.
It is not allowed to have the same name of a field/variable and its type specifier.
Semantic checking is also performed during flattening. As we can see when simulating IllegalTypeAsField we get a warning for trying to name our variable Voltage, which is the same as the type name.
By changing the name of the first field/variable to voltage1, we fix the problem.