
When deconstructing a struct tuple, you must include the struct keyword, let struct(x, y) = st
:) This is why I named this issue "inconsistence..."
Hmm, now I see. You are specifically referring to let _ = match st with x, y... Yes this is inconsistent.
Not 100% sure this is a bug yet; but I imagine that it is.
@TIHan If it helps, F# 4.5 requires struct keyword in match st .... It seems structness inference for tuples was added at the time when it was added for anon records, as an unexpected side effect. Also, the inconsistence may be the result of the luck of pattern matching support for anon records.
As per the spec: https://github.com/fsharp/fslang-design/blob/master/FSharp-4.6/FS-1030-anonymous-records.md#structness-inference
For consistency, the structness of anonymous tuple expressions and types is now also inferred from the known type.
This was listed as a "possible extension" in the spec for struct tuples for F# 4.1: https://github.com/fsharp/fslang-design/blob/master/FSharp-4.1/FS-1006-struct-tuples.md#possible-extension-structness-inference
But has clearly been implemented. So the fact that it works for match but not deconstruction-based pattern matching is a bug.
This is by design, but a fantastic example of how inconsistencies appear to arise in the user experience when we infer information from the known type, and why we've been very cautious about using this information in F#.
When analyzing the pattern x,y in let x, y = ... the known type is not yet a tuple type of any kind. So we progress on the assumption that it's a reference tuple. We do not create an inference parameter to represent the unknown kind of the tuple
So fundamentally this is a difference between the left-to-right nature of things in
let x, y = ...
and
match ... with x,y -> ...
There could be an argument that the pattern in a simple let (as opposed to a let rec) should be analysed after analysing the expression being bound. However this is a separate issue and would be a significant breaking change (because the left patter can cause type information to flow into the right pattern)