F#: Cannot destucture a tuple of records to private values - by Edward D. Brey

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


2
0
Sign in
to vote
ID 726415 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 2/23/2012 12:11:04 PM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration

Description

The F# compiler reports an error when using a module-level let binding to bind two private values to records in a tuple.
Sign in to post a comment.
Posted by Edward D. Brey on 3/12/2012 at 1:56 PM
Thanks, Donna. That helps explain things a bit better. It was confusing when the issue was closed as "Won't fix". That seemed to indicate it was a bug. Isn't there a "Not a bug" status?

I tried to see if I could find in the F# 2.0 language spec the statement that clarifies that the access specifier is not allowed. The grammar in 6.6.1 ("mutable access pat typar-defns return-type = rhs-expr") makes it look like "let private b,c = {F=2},{F=3}" would be OK, whereas adding the second "private" would be illegal. But I'm not so sure, since the "private b, private c" form compiles if "T" and "a" are public.

There a statement that appears to be related in section 7: "Attributes and accessibility annotations on patterns are not permitted except on patterns that are in argument position for a “let” binding in a module or a member-binding in a type." However, it's not clear what it means to be in argument position.

I agree that this isn't a major issue, but it would be good know what the rules are and to get better help from the compiler when the binding is invalid.
Posted by Microsoft on 3/12/2012 at 10:44 AM
Apologies for the delay in response. I realize it would be useful to be able to use the syntax in this manner, but this just isn't the way that "let" parsing is specifed. This would be a feature request, and doesn't seem like a common case. However, if you would really like to see this change be made, you can create a UserVoice suggestion (http://visualstudio.uservoice.com/forums/121579-visual-studio/category/30935-f-) and see if you can get some more support for the feature.

Donna Malayeri
Program Manager, Visual Studio F#
Posted by Edward D. Brey on 2/24/2012 at 1:08 PM
Any comment on why this bug won't be fixed? It's surprising, especially considering that F# is so new and has such a long future ahead of it.
Posted by MS-Moderator10 [Feedback Moderator] on 2/23/2012 at 9:08 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by danieldelton on 2/23/2012 at 12:53 PM
To add a little more to this: the intermediate value (tuple, record, list, etc.) that's being destructured is created as an 'internal' field of the enclosing module. This causes the "type 'T is less accessible than the value" error. It seems the visibility of the intermediate value needs to take into account the accessibility modifier of the let binding.
Posted by MS-Moderator01 on 2/23/2012 at 12:45 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Posted by danieldelton on 2/23/2012 at 12:40 PM
See this StackOverflow question for more examples: http://stackoverflow.com/a/9384938/162396