Uh oh!
There was an error while loading. Please reload this page.
Parens: tweak sensitive indentation handling - #16248
Conversation
* There are certain scenarios where we must consider both the context outside of a pair of parentheses as well as the inside in order to reintegrate the inner construct into the outer context after removing the parentheses.
…uter-sensitive-indentation
brianrourkeboll
commented
Nov 10, 2023
Hmm, I think I see one bug... Let me fix that. |
brianrourkeboll
commented
Nov 10, 2023
Tricky, tricky: fsharp/src/FSharp.Core/eventmodule.fs Lines 74 to 79 in 9a0b9bf |
brianrourkeboll
commented
Nov 10, 2023
Expect some more PRs after this one, unfortunately—running fix-all on FSharp.Core is surfacing some other oddities I hadn't thought of, like the fact that parens aren't needed after typeT(x,y)=new(x)= T (x,3)// Can remove parens: `new x = T (x, 3)`.or in this: typeT(x,y)=new(x,y,z)= T (x, y)new(x)= T (x,3)// Can remove parens: `new x = T (x, 3)`.but they are required if there's another constructor and it comes after: typeT(x,y)=new(x)= T (x,3)// Cannot remove; removing the parens causes parse errors below.new(x,y,_z)= T (x, y)Or the fact that this is fine: typeC=abstractM :unit->unitlet_={new C withoverride_.M()=()}// I.e., `override _.M (())` can be simplified to `override _.M ()`but this requires typeC<'T>=abstractM :'T->unitlet_={new C<unit>withoverride_.M(())=()}Real example: fsharp/src/FSharp.Core/printf.fs Lines 1074 to 1078 in 9a0b9bf |
psfinaki
commented
Nov 10, 2023
We are totally ready for the followups :) |
psfinaki
commented
Nov 14, 2023
@brianrourkeboll this LGTM - is there anything else you plan to add here? |
@psfinaki Nope, this one should be all set. |
majocha
commented
Nov 15, 2023
It seems this test case started to fail at some point: Apparently because it's not being caught by the diagnostics. |
Another followup to #16079.
There are certain cases where we must consider both the context outside of a pair of parentheses as well as the inside in order to reintegrate the inner construct into the outer context after removing the parentheses. That is, sometimes we cannot simply remove the parentheses in place, but we must instead shift the entire parenthesized multiline expression left by one space.
For example:
must become
not
Or here's a real-world example from FSharp.Core:
fsharp/src/Compiler/Utilities/sformat.fs
Lines 891 to 901 in 9e7ec64