fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

Recover unfinished binary expressions

Open auduchinok opened this issue 2 years ago • 1 comments

Adds parser recovery for unfinished binary app expressions that have their right operand missing and that are placed before other declarations or before the end of file.

End of file:

1 +

Before type decl:

1 + 

type T = int

Before attributes in a decl:

1 +

[<Attr>]
let x = 1

Thanks to @dsyme for guiding me on where to look at.

I'll start adding new tests when the existing ones are green.

auduchinok avatar Jul 07 '22 17:07 auduchinok

The following case got broken:

let f
    (
        a,
        [<A>] b
    ) = ()

I'm (hopefully, temporarily) undoing the before-[< recovery to see if anything else gets broken.

auduchinok avatar Jul 07 '22 18:07 auduchinok

@auduchinok hey there, would you like to continue on that? I can help with resolving conflicts if needed. Also, probably some testing would be useful here.

psfinaki avatar Oct 26 '22 12:10 psfinaki

@psfinaki Yes, I'm going to get back to it. Perhaps I'll need to rethink the approach here... I'll resolve the conflicts myself, thanks!

auduchinok avatar Oct 26 '22 12:10 auduchinok

@auduchinok, thanks, reach out if you need any help!

psfinaki avatar Oct 26 '22 12:10 psfinaki

This has been superseded by https://github.com/dotnet/fsharp/pull/15255 and https://github.com/dotnet/fsharp/pull/15334.

The situation with top-level expressions (i.e. at the module scope) is not as good as I'd want it to be, but it'd be really difficult to change it. The good news are local binary expressions seem to be much more common and PRs above improve the recovery very noticeably for them.

auduchinok avatar Jun 20 '23 13:06 auduchinok