-
Notifications
You must be signed in to change notification settings - Fork 847
Description
Applying the attribute SkipLocalsInitAttribute is an unsafe operation, but does not raise the FS0009 warning.
Repro steps
type Rain() =
[<SkipLocalsInit>]
member _.ItPours(?msg: string) =
let message= defaultArg mname "absent"
$"Message: {message}"Expected behavior
According to the docs, this is an unsafe operation.
F# issues the FS0009 warning for unsafe operations (like fixed and using nativeptr and the like). This warning should be thrown when using SkipLocalsInit as well.
This is akin to using the unsafe keyword in C#, which is indeed required for this attribute.
Actual behavior
The warning is not thrown.
Related information
- Original implementation: Support SkipLocalsinit #11267, by @kerams, perhaps you know whether there was a decision here?
- Original suggestion: Support [<SkipLocalsInit>] fsharp/fslang-suggestions#990
- RFC: not found
The suggestion does not mention the term unsafe, but @dsyme mentioned
It's also in the realm of a "allow generation of unverifiable code for performance reasons" feature
which further cements that this is unsafe and that FS0009 should be shown here.
Since this is just a warning, I hope this can be added to F# still, without being considered a backward compatibility issue.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status