Migrating to the latest FSharp.Core generates warnings

Viewed 69

I've just migrated my project to use FSharp.Core 6.0.3 instead of 6.0.1. I noticed that now in my code there are warnings every time I refer to uint32 with a unit of measure. More specificaly:

  • LanguagePrimitives.UInt32WithMeasure function
  • uint32<cm> as a parameter type

I guess it's safe to set a compile flag to ignore this warning, but I'd like to understand what has happened and why this is now considered a problem.

The exact warning message is: FS0057: Experimental library feature, requires '--langversion:preview'. This warning can be disabled using '--nowarn:57' or '#nowarn "57"'.

2 Answers

Older versions of F# only supported units of measure for signed integer values (and floating point).

According to this comment on an F# language issue, units of measure are now supported experimentally for unsigned integers as well.

In playing around with an example, I noticed that you can avoid the warning by using uint<cm> instead of uint32<cm>, but I'm not sure if this is intentional.

My $0.02 to this: I've reviewed the fsharp GH repo and found the declaration of LanguagePrimitives.UInt32WithMeasure.

[<Experimental("Experimental library feature, requires '--langversion:preview'")>]
val inline UInt32WithMeasure: input: uint -> uint<'Measure>

However, the Experimental attribute was added in this commit, so I guess that FSharp.Core 6.0.1 must have been created before that and therefore it doesn't report the warning.

Related