Open alfonsogarciacaro opened 5 years ago
Definitely a bug. @alfonsogarciacaro Does this affect Fable anywhere critical?
Yes. These two statements print different values in Fable but not in dotnet:
let value = 0.5M
value.GetType().FullName |> printfn "%s" // Microsoft.FSharp.Core.decimal`1
typeof<decimal>.FullName |> printfn "%s" // System.Decimal
But I've found a workaround for now, not sure how correct it is.
Recently we've found the problem is aggravated with measure annotated abbreviations outside FSharp.Core, like the ones in FSharp.UMX. In that case I haven't found a way to access the abbreviated type, the work around linked in the previous comment doesn't work, not sure why (though I guess it's because the measure annotated abbreviations are hard-coded somewhere in the F# compiler).
You should look for MeasureAnnotatedAbbreviation
attribute (MeasureAnnotatedAbbreviationAttribute) in the attributes of the type definition. In this case, the type represents a new type definition that is a measure-annotated version of the existing type definition. It acts like a new type, and is not automatically expanded to the underlying type except when instantiated with the unit-of-measure "1"
If I get the typed AST of
let value = 0.7833263478179128134089M
, the type ofvalue
becomes "Microsoft.FSharp.Core.decimal`1", whose.AbbreviatedType
is "System.Decimal". But if I check.IsAbbreviation
this evals to false, which makes it difficult to know whether I should check the abbreviation or not.