Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating anonymous record based on a function call with a list arg fails #1749

Closed
isaacabraham opened this issue May 23, 2021 · 5 comments · Fixed by #2096
Closed

Creating anonymous record based on a function call with a list arg fails #1749

isaacabraham opened this issue May 23, 2021 · 5 comments · Fixed by #2096
Labels
bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet!

Comments

@isaacabraham
Copy link

Using Fantomas v4.5.0-alpha-019. Unfortunately I can't reproduce this in the tool - I suspect because I've changed some options (.editorconfig below), but I've narrowed it down to the following:

module MyModule

type Foo = static member Create a = {| Name = "Isaac" |}
type Bar() = member _.Create (a,b) = ()
let bar = Bar()
type Thing = static member Stuff = 123
let x = {| Foo.Create ([ bar.Create(Thing.Stuff, Thing.Stuff) ]) with Age = 41 |}

I've tried removing various elements from this, some of which make the code valid e.g. removing the parens around the list in the last line.

root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false

[*.fs]
fsharp_space_before_lowercase_invocation = true
fsharp_space_before_uppercase_invocation = true
fsharp_space_before_colon = true
fsharp_multiline_block_brackets_on_same_column = true

[src/Tests/*.fs]
fsharp_single_argument_web_mode = true
@nojaf
Copy link
Contributor

nojaf commented May 23, 2021

Hey Isaac, could you please use our online tool anyway?
If you click the menu button (when in the Fantomas tab)
image

You can tweak the settings of the online tool:
image

Thanks

@isaacabraham
Copy link
Author

@nojaf ah, thanks - i didn't notice that.

https://fsprojects.github.io/fantomas-tools/#/fantomas/preview?data=N4KABGBEDGD2AmBTSAuKBbBBXANosAsgJ4HZ4A6ATuQHZW0AuRADvgGKyxgC8YAzgwCGDAJbQw6ROgBGiSmADClRMPyCeYYAB8wAOUGSN5SAEk%2BgwdGNgtAX3o0mrMACFBlABQBKDZJlywAH0AOiUVBnwPQQAaaR9ebwc8B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dBcFEBagw4SgbIYCy8jizmDK8%2BTfL5kt4AIZWRFVxB1c15aEOgAoKzwuRAnOF62plzbNFZvHuThPXhqO4yyYmyhBCIX1KDlAQ6bat7GdBdbPZEjkFYJwakvKwkOh8mDJWlEOw4jqOGEF4XRfFyXiY9uX9wVpWcBV%2BVreEbXdcJ-W7VS3OC-DyORAEM2G4tpuSxt7jfPtx2LJdkQ3cgavvtrn20-1A7M5xDpKtzs6ADU0xcYp4FWGO7Pehecfl5eOfbgON9G7fpTYaa8NRg%2BSWP2f6Zgs-PtlxfRN%2BtfdOAMQwdBOg-foM1YAMAAOJ9HhojRAyNUYn3RvHRkzMtq4zAgNVeGdAagg6CDbe5tLYuDdNAAA1i4UOVC%2Bh8DqnUSsWF0ToDRmpesnUmbdRZttHBJVgFcztKTXOuhECnDIX0KcSodasDmhDGgFxUbXBJJxYWlcYIRXPrw7B8VOw30OhvHmucADSiBEDMAuldGgxImGSEDMGTRHVtFYMvkaFesY14EIgB0Q2ECbrBT4AUVBDMXFez4Xo-a%2BDQFB1zuSUoeAJolCFkqJ6iBpCkCQO1W6YTk6tgVrpQRHdMw51pJAa4C0Sg0CfjQF%2B7pyRVOEFgZQeRYDVVSZUHKtItG-yTt7fh%2Biim3zBF0LuZSKkWRoJUZECp3QlDUbUeRxQlHYWyXxbh2MdFuMif7QxIyt5lMHqIBxMoDDSHgIINCsAUalDERI%2BUayuEJ0weE3R-UBF4JATBLo98ykzX7oIaQeAAn9wKHUIgjhpSPNyf06ESp4D%2BgcQ0IgeAolfNpF0cBZSfQIoDA8u2lAcBNHnr0muACCm4M8dE75xCylmIse0xwxIaGCFqbHEMPSsZfQvkvAZaKhGZhEWU8hrLKEOL4BNKaJIxECEQKbUh8oEFIxRqsv8nCYURPeYMz5AqcRdGMWUholAxAMEyY47pzjekfCODSGEfA2Ao3%2BFo2wQA

@nojaf
Copy link
Contributor

nojaf commented May 25, 2021

Thank you, I see what the problem now is.
When printing the long version of an Anonymous record in

let longExpression =
ifAlignBrackets
(genMultilineAnonRecordAlignBrackets isStruct fields copyInfo astContext)
(genMultilineAnonRecord isStruct fields copyInfo astContext)

Both styles print the copy expression following the normal indentation flow.
In your example, the expression needs to be indented by the current column it starts.
To resolve this, I believe you would need to wrap the expression inside the atCurrentColumnIndent helper function.

genExpr astContext e

Something like:

    let copyExpr fieldsExpr e =
        atCurrentColumnIndent (genExpr astContext e)
        +> (!- " with"
            +> indent
            +> whenShortIndent indent
            +> sepNln
            +> fieldsExpr
            +> whenShortIndent unindent
            +> unindent)

Are you interested in submitting a PR for this?

@nojaf nojaf added bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet! and removed discussion labels May 25, 2021
@isaacabraham
Copy link
Author

I'll ask someone on the team if they'd be interested - for me, it's not something that I have the time to commit to doing, I have enough projects I'm working on currently.

Please don't take that to mean that I expect you to do it - let's see if someone has the time and interest in doing it - but I'm glad I've at least reported this to you so someone can pick it up.

For me, we're not depending on Fantomas at the moment and this has been a useful experiment to see how and where it works (definitely way better than when I last tried it a couple of years back).

@nojaf
Copy link
Contributor

nojaf commented May 26, 2021

Hey Isaac, this is a good response thank you. I'm well aware of all your adventures in the F# community so this response is quite sensible.

I also like the fact that you don't have any expectations on me personally solving this. From my side I don't have the aspiration to solve everybody's reported bug. Sometimes I just don't have a stake in the issue, so when that happens I usually leave some clues on what is going on and I ask the reporter if they are interested in taking a stab at this. Sometimes this works, sometimes it doesn't 😊.

If somebody of your team is willing to pick this one up, I recommend checking out our Contribution Guidelines and optionally a couple of videos from the YouTube channel.

In case, you were using Fantomas, you can always ignore formatting the file using a .fantomasignore file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (soundness) good first issue Long hanging fruit: easy issue to get your feet wet!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants