tweag / nickel

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

VSCode extension does not show hints for functions annotated with record contract #1885

Closed suimong closed 2 months ago

suimong commented 2 months ago

Is your feature request related to a problem? Please describe.

Consider the following example:

{
  Schema = {
    foo,
    bar
      | {
        baz,
      }
  },
  some_func
    | Schema -> Dyn
    = fun src =>
      {
        some_val = src.bar.baz
      }
      ,
  some_record = {
    src | Schema,
    some_val  = src.bar.baz
  }
}

within some_record, the extension beautifully shows hints on the structure of Schema as I type after some_val = src., whereas within some_func, no hint is available after some_val = src.

Describe the solution you'd like Enable hints for function parameters that are annotated with record contract.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context

> nickel --version  
nickel-lang-cli nickel 1.5.0 (rev 13ffc85)
yannham commented 2 months ago

Assigning myself because I don't think this needs any support on the LSP side (I mean, not directly), but rather on the typechecker side. As far as I can tell, it should be simple to do, just need a bit of special casing (when walking an annotated term whose content is a function and type is a function type, retype() the function parameter with the domain of the function type)