Why is RequireQualifiedAccess not working, which leads to a compilation error, but not if I use open?

I'm having problems with RequireQualifiedAccess : despite the attribute, the join case obscures the type. Oddly enough, the error only appears if I use qualified access to the closing module, and not inside it, or if I open it:

module Module = type [<RequireQualifiedAccess>] Du = | SomeCase type [<RequireQualifiedAccess>] SuperDu = | Du of Du let valid = Du.SomeCase // Valid, as expected let invalid = Module.Du.SomeCase // Not defined?!? open Module let validToo = Du.SomeCase // Wait, this is valid again? 

In an invalid line, a warning first appears that using .Du without qualified access is deprecated, as if I referenced SuperDu.Du , then it gives an error that is not defined by SomeCase .

I have always believed that using open X equivalent to the X. prefix to all definitions taken from this module. But this is obviously not ...?

What's going on here? Should I avoid this kind of name collision despite RequireQualifiedAccess ? Is this a compiler error?

+7
f #
source share
1 answer
+3
source share

All Articles