Parenthesize lambda in non-last record field on single line#3247
Parenthesize lambda in non-last record field on single line#3247nojaf merged 3 commits intofsprojects:mainfrom
Conversation
When a record expression is collapsed to a single line, a `fun` lambda in a non-last field produces invalid F# because the lambda body extends to the end of the expression, swallowing subsequent fields. Wrap such lambdas in parentheses, matching the existing approach for tuples. Fixes fsprojects#3246 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🤖 This is an automated response from Repo Assist. Welcome to Fantomas, @randrag! 🎉 Thank you for your first contribution — a well-documented soundness bug with a ready fix is exactly what the project needs. Your analysis is spot on: in F#, A few tips for a smooth review:
Looking forward to seeing this reviewed and merged!
|
|
Hi @randrag, thanks for the PR, this looks reasonable. |
|
Hi @nojaf, I'm happy with it as it is. Thank you so much for Fantomas, which we have recently adopted to our solution of more than 2,000 F# files. This was the only bug we picked up when initially reformatting them all. Regards Roland |
|
I think I can't push because this is coming from an organization fork? |
Thanks for your kind words 😊! Also cool to see that this was the only problem you had! |
When a record expression is collapsed to a single line, a
funlambda in a non-last field produces invalid F# because the lambda body extends to the end of the expression, swallowing subsequent fields.This wraps such lambdas in parentheses, matching the existing approach used for tuple expressions (
IsLambdaOrIfThenElsecheck ingenExprforExprTupleNode).Fixes #3246
Please verify your pull request is respecting our Pull request ground rules.