fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Go to Metadata - static field handling is wrong

Open cartermp opened this issue 4 years ago • 2 comments

Navigate to System.Char.

Notice that the MaxValue and MinValue fields are listed as static vals. This is wrong. They cannot just be marked with [<DefaultValue>] either.

image

If we follow the error message you would get if you tried to write this into your own signature, it compiles:

image

But this is no longer correct, since the value in question is a public const field.

cartermp avatar May 04 '21 23:05 cartermp

This may be a current limitation in the language, actually. We don't really have a good way to declare these things in F# code today. We can probably still get things to "work" in metadata as source view though, at least getting colors and maybe navigation going.

cartermp avatar May 05 '21 00:05 cartermp

Some context from http://www.ianvoyce.com/index.php/2010/10/01/public-static-fields-gone-from-f-2-0/:

We deliberately removed the ability to create public static fields in Beta2/RC, because of issues associated with initialization of the fields (i.e. ensuring the “static do” bindings are run correctly, and if they are run, then they are run for the whole file, in the right order, with no deadlocks or uninitialized access when initialization occurs from multiple threads).

auduchinok avatar May 05 '21 10:05 auduchinok