-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[<RequireQualifiedAccess>] allows access to DU member if qualified only by module name #95
Comments
I think I found the issue. In https://github.com/forki/visualfsharp/blob/fsharp4/src/fsharp/nameres.fs#L1653 we search for UnionCases inside of modules. But we should only do this for Unions without RequireQualifiedAccessAttribute. As a quickhack I checked if the DU in question has any attributes: This solves all DU access cases for me, but of course it's not the correct fix. What I really want is to check if we have RequiredQualifiedAttribute inside of tyCon.Attribs. But here I'm stuck. I already discoverd things like
but I don't have a If someone can point me in the right direction then I could try to come up with a PR which contains tests and a better fix. |
There's a TcGlobals in ncenv. Here are the notes from our discussion on twitter:
|
…ss was set - closes dotnet#95
…ss was set - closes dotnet#95
…cess was set - closes dotnet#95
…cess was set - closes dotnet#95
@tpetricek could you please review? |
as @dsyme already pointed out we have the same issue for records.
I'll try to update #103 with a fix for this. |
ok the record case seems much harder to fix since we don't return ideas? |
…cess was set - closes dotnet#95
It's possibe to raise the warning directly in https://github.com/Microsoft/visualfsharp/blob/5eb0657f6d9a5e4399062325a627c6c1812174cb/src/fsharp/nameres.fs#L2145 (this is probably less clean as @dsyme described above, but also less invasive). Strangely the code is processed twice. It seems it needs further investigation. |
Ok the message is raised twice sind modulSearch is called twice in https://github.com/Microsoft/visualfsharp/blob/5eb0657f6d9a5e4399062325a627c6c1812174cb/src/fsharp/nameres.fs#L2208 |
It looks like you'd need to return a pair (RecdFieldRef * bool) . Add a new Some quite fiddly work in BuildRefMap is then needed, until you actually get the flag through to the point where we commit to a partifular resolution for the field at the end of that function, at the point where we call "CheckRecdFieldAccessible". FWIW BuildFieldMap is intersecting the possible types being constructed so "{A=e1;B=e2}" and "{A=e1;C=e2}" may resolve to different record type constructions if {A,B} and {A,C} are enough to disambiguate which record type is being constructed. |
…ccess was set - relates to dotnet#95
…edAccess was set - relates to dotnet#95
…edAccess was set - relates to dotnet#95
…dAccess was set - relates to dotnet#95
Hi, is this issue resolved in the version of F# available in Visual Studio 2015 rc? |
@huwman yes, it should be |
This was originally opened at codepelex by latkin
Repro in VS 2013. Reported by Tomas P via fsbugs.
The RequireQualifiedAccess attribute should force users to include the DU name when accessing a DU member. However as shown below, it incorrectly allows access using only the module name.
The text was updated successfully, but these errors were encountered: