unison icon indicating copy to clipboard operation
unison copied to clipboard

Term prefixed with underscore considered ambiguous when it shouldn't be (and round-trip issue)

Open alvaroc1 opened this issue 1 year ago • 1 comments

Version: release/0.5.16

type Hello = {_value : Nat}

doStuff = _value.modify
Screenshot 2024-02-08 at 3 44 29 PM

There's only one definition of _value in the project, coming from the Hello type.

It works fine with a longer prefix or without the underscore

When editing, the pretty-printer prints it as shown also causing round-trip issues.

alvaroc1 avatar Feb 08 '24 22:02 alvaroc1

There's also a weird behaviour when you're trying to edit some of the generated functions (either intentionally, or they might get spitted out on update command related to other custom definitions).

Let's expand @alvaroc1's example a bit to:

type Hello = { _value : Nat, value : Nat, value_ : Nat }

Now run edit Hello._value command, and see how editor's LSP starts complaining with:

  I found a value  of type:  Hello ->{𝕖} Nat
  where I expected to find:  Nat

      1 | Hello._value : Hello -> Nat
      2 | Hello._value = cases Hello _value -> _value

    from right here:

      1 | Hello._value : Hello -> Nat

But running edit Hello.value (without _ prefix) would not have the same issues. The same applies to Hello.value_ version.

Which tells us that compiler having trouble capturing variables in pattern match case when they start with _ (underscore).

I'm not sure if it's somehow related to #4746, but worth the mention.

andreystepanov avatar Mar 28 '24 10:03 andreystepanov

Duplicate of #2822.

sellout avatar Aug 15 '24 20:08 sellout