rescript-association / reanalyze

Experimental analyses for ReScript and OCaml: globally dead values/types, exception analysis, and termination analysis.
MIT License
277 stars 20 forks source link

decorating functions in pipe chains? #164

Open AlexMoutonNoble opened 2 years ago

AlexMoutonNoble commented 2 years ago

Hi Christiano and all Wondering if youve considered decoration for functions called in pipe chains? I wasnt able to add the decorator where I thought it would go

Thanks for the quick feedback about literal divides. Alex

cristianoc commented 2 years ago

Hi, do you have an example?

AlexMoutonNoble commented 2 years ago
  if columns->Js.Array.length >= 2 {
    let dataRecordIdColumn = @doesNotRaise columns->Belt.Array.getExn(0)
   ...
  }
cristianoc commented 2 years ago

One can annotate the function Belt.Array.getExn or the result of the application. In the case of pipe, there are issues with the parsing of the annotation.

See examples in https://github.com/rescript-association/reanalyze/pull/165

This should be moved to an issue in the https://github.com/rescript-lang/syntax repository: 1 (@doesNotRaise [])->Belt.Array.getExn(0) formats to @doesNotRaise []->Belt.Array.getExn(0) so this is annotating the argument not the result 2 @doesNotRaise ([]->Belt.Array.getExn(0)) formats to []->Belt.Array.getExn(0) so it completely destroys the annotation.

For your workaround, you can annotate the function for now.

AlexMoutonNoble commented 2 years ago

Rad. Thanks for the examples. I need to take more time looking in there as well