You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With more than one value in an enum, mixing a parameterized role into the value yields the obtuse comile-time error "Incompatible MROs in P6opaque rebless for types Int+{MixedInRoleName[Str]} mixin and EnumName". This does not happen when there is only one enum value, nor when the role is unparameterized.
It lurks in my memory that values of an enum has to be of the same type. No way for me to recall where I saw this, neither I can find the place at the moment.
Trying to mix a number and a string results in exactly the same error. Apparently, the error itself is LTA, but otherwise it seems to be legal.
The particular example case can be easily fixed with this:
Interesting. I suppose technically roles that are parameterized differently do cause the resulting type to be different. Still, might be worth leaving this open to improve the error message?
ab5tract
added
LTA
Less Than Awesome; typically an error message that could be better
objects
OOP, classes, instances, roles, inheritance, (sub)methods, etc.
labels
Jan 22, 2024
I suppose technically roles that are parameterized differently do cause the resulting type to be different.
Yes, you're correct. This is why the approach you took in your example is not the best one in some scenarios. Imagine one having thousands of objects to be marked with roles-labels. In this case they get thousands of additional types, each consuming memory both to hold its VM representation and to maintain metaobject data related to the type.
The Problem
With more than one value in an
enum
, mixing a parameterized role into the value yields the obtuse comile-time error "Incompatible MROs in P6opaque rebless for types Int+{MixedInRoleName[Str]} mixin and EnumName". This does not happen when there is only one enum value, nor when the role is unparameterized.Steps to Reproduce
Environment
The text was updated successfully, but these errors were encountered: