tweag / nickel

Better configuration for less
https://nickel-lang.org/
MIT License
2.23k stars 85 forks source link

A completion candidate can shadow a more informative one #1933

Closed thufschmitt closed 2 weeks ago

thufschmitt commented 1 month ago

Describe the bug

A completion can sometimes have several candidates for the same term, in which case it's possible that one with less information (doc, type) shadows another one

To Reproduce

This works as expected, the completion will suggest foo as a Number with some documentation:

let C = { foo | Number | doc "Some documentation" } in
{
  f<CURSOR>
} | C

This will suggest a completion for foo, but without any meta information:

let C = { foo | Number | doc "Some documentation" } in
{
  foo,
  f<CURSOR>
} | C

Expected behavior

Don't let the local foo shadow the information from the outer one

Environment

yannham commented 1 month ago

@jneem I guess what we want is to somehow merge the duplicate suggestions (in the sense of nickel_lang_core::combine::Combine, but taking care of not duplicating types and contracts if they are the same)

yannham commented 4 weeks ago

It turns out to be not as as simple as expected. @thufschmitt May I ask what is the intended use-case? looking at your example once again, it's very strange to declare a local foo with any value to then redefine it a second time in the same record.

However, maybe what you're getting it is that if you do this:

{
  foo,
  bar = f<CURSOR> ,
} | C

Then it makes sense and you lose the information as well?

thufschmitt commented 4 weeks ago

May I ask what is the intended use-case?

Something like

{
  shells = organist.shells.Bash,
  sh<cursor>, # I'd like to extend the bash shell
} | organist.OrganistExpression