MATLAB: Do I get the error “Unable to access the enumeration constant” in Stateflow R2019a

stateflow

I have a model containing a Stateflow chart, which uses the enumerated type "BasicColors" in a local Stateflow variable with the same name. The enumerated type is defined in a data dictionary.
The model works fine in R2018b. However, when I tried to run the model in R2019a, I got the error:
Unable to access the enumeration constant 'Red' from a variable. Use the enumeration name: 'BasicColors.Red'.
Transition < '[Basic...action}'
>"BasicColors"
The error message is referring to the following statement in a transition condition:
BasicColors == BasicColors.Red

Best Answer

Starting in R2019a, Stateflow will error out when there is a name confict between a local variable name and enum type class identifier.
To distinguish the "BasicColors" variable from the "BasicColors" enumeration, rename the local Stateflow variable to a name that is different from the enum class identifier (for example "MyBasicColor"). The according transition statement will be:
MyBasicColor == BasicColors.Red