Function parameter bound multiple times - bug?

The following code is allowed by the compiler:

let f x x = x

Yet this is not:

match 1, 2 with x, x -> x

With error:

Error: Variable x is bound several times in this matching

Is this a known issue and considered a bug? If not, why not?

I think this is because one of these attempts to bind x twice simultaneously, whereas one binds x and then immediately shadows it:

Compare the desugaring:

let f x x = x

let f = fun x -> fun x -> x

whereas the match statement has a single pattern (x, x) that binds the same name twice.


Yeah that makes sense. I just wonder if in this case it would be better to be a bit less ‘sugary’ and refuse to proceed with these duplicated parameter names when we know for sure it’s a mistake.

With warning 27 enabled, it is reported as “unused variable x.”