merlin icon indicating copy to clipboard operation
merlin copied to clipboard

Fix: destructing record field in pattern

Open ulugbekna opened this issue 3 years ago • 2 comments

First commit adds a test showing the problem; the second one fixes it.

I hope I'm not leaving out some edge cases, went with the seemingly easiest fix.

ulugbekna avatar Feb 08 '22 15:02 ulugbekna

Doesn't your code break a call to destruct on x on the following example:

type r = { x : int }
type r_out = { r : r; y : string }

let f ({ r = x ; y } : r_out) = ()

by producing (in the end) { r = r = { x }; y }?

Generally to detect punning you'll want to have a look at the location of the nodes.

Also, I'm surprised that the behavior depends on the content of the field. :shrug:

trefis avatar Feb 08 '22 15:02 trefis

Indeed, the fix is incorrect. I’ll see what to do about it

Also, I'm surprised that the behavior depends on the content of the field. 🤷

I don’t quite understand what you mean

thanks for quick review :-)

ulugbekna avatar Feb 08 '22 17:02 ulugbekna