You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parentheses are not normally required around a tuple when using set/assignment syntax, including with an indexer, since , has higher precedence than <-.
When the assignment operation happens to translate to a method call like set_Item(key: …, value: …*…), however, parentheses are required — but only when using the x.[…] <- … syntax (i.e., with a dot .); when using the x[…] <- … syntax (without a dot), parentheses are never required.
openSystem.Collections.Genericletxs= Array.zeroCreate 1// OK.
xs[0]<-(2,3,4)// OK.
xs[0]<-2,3,4// OK.
xs.[0]<-(2,3,4)// OK.
xs.[0]<-2,3,4letys= Dictionary ()// OK.
ys[0]<-(2,3,4)// OK.
ys[0]<-2,3,4// OK.
ys.[0]<-(2,3,4)// error FS0501: The member or object constructor 'Item' takes 2 argument(s) but is here given 4.// The required signature is 'Dictionary.set_Item(key: int, value: int * int * int) : unit'.
ys.[0]<-2,3,4// OK.
ys.Item 0<-(2,3,4)// error FS0501: The member or object constructor 'Item' takes 2 argument(s) but is here given 4.// The required signature is 'Dictionary.set_Item(key: int, value: int * int * int) : unit'.
ys.Item 0<-2,3,4// OK.(ys).Item 0<-(2,3,4)// error FS0501: The member or object constructor 'Item' takes 2 argument(s) but is here given 4.// The required signature is 'Dictionary.set_Item(key: int, value: int * int * int) : unit'.(ys).Item 0<-2,3,4
Expected behavior
The syntactic precedence of , and <- should not change due to type information or presence of a . in the indexing syntax.
Actual behavior
The syntactic precedence of , and <- appear to change depending on type information and presence of a . in the indexing syntax.
Known workarounds
For the parentheses analyzer: always assume parentheses are required, or check the typed tree to see if the compiled translation involves a method call like set_Item(key: …, value: …*…).
The text was updated successfully, but these errors were encountered:
Repro steps
Parentheses are not normally required around a tuple when using set/assignment syntax, including with an indexer, since
,
has higher precedence than<-
.When the assignment operation happens to translate to a method call like
set_Item(key: …, value: …*…)
, however, parentheses are required — but only when using thex.[…] <- …
syntax (i.e., with a dot.
); when using thex[…] <- …
syntax (without a dot), parentheses are never required.Expected behavior
The syntactic precedence of
,
and<-
should not change due to type information or presence of a.
in the indexing syntax.Actual behavior
The syntactic precedence of
,
and<-
appear to change depending on type information and presence of a.
in the indexing syntax.Known workarounds
For the parentheses analyzer: always assume parentheses are required, or check the typed tree to see if the compiled translation involves a method call like
set_Item(key: …, value: …*…)
.The text was updated successfully, but these errors were encountered: