Open remitbri opened 4 months ago
There's no as
support in poly variants, because they are inferred, and the declaration can't be a source of truth.
I also remember struggling with assuming that polymorphic variants support @as
. Maybe there should be a compiler error when trying to apply as
to a polymorphic variant instead of silently ignoring the attribute.
Yes adding at least a warning would be good.
The compiler already has a mechanism for detecting unused attributes. However, it got broken when moving from @bs.xxx
to @xxx
.
We already fixed that on master. So in ReScript 12, unused @as
will be detected.
ReScript 11, unfortunately, only detects unused @bs.as
(see Playground).
Hi
ReScript version: v11.x.x
When using plain variants with an
@as
, coercing to string produces the expected result. E.gWhen using polymorphic variants with an
@as
, coercing to string produces an unexpected resultI'm not sure whether this is expected or if I'm supposed to write
Playground here