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

Provide more information when string merge failed #1904

Closed
nojaf opened this issue Sep 29, 2021 · 0 comments · Fixed by #1909
Closed

Provide more information when string merge failed #1904

nojaf opened this issue Sep 29, 2021 · 0 comments · Fixed by #1909

Comments

@nojaf
Copy link
Contributor

nojaf commented Sep 29, 2021

Currently, when you format a file that contains multiple defines, it might happen that fails due to

Fantomas is trying to format the input multiple times due to the detect of multiple defines.
There is a problem with merging all the code back together. Please raise an issue at https://github.com/fsprojects/fantomas/issues.

This tells you that what the problem is but doesn't pinpoint anything useful at all.
In essence, one (of more) compiler defines combination will contain fewer hash directives (#if FOO) than the other results.
And so, we assume it cannot be merged.

It would be beneficial if we at least told which combination had how many fragments inside the merge function.

let merge (newline: string) (a: string) (b: string) : string =
let aChunks = splitWhenHash newline a
let bChunks = splitWhenHash newline b
if List.length aChunks <> List.length bChunks then
Dbg.print (aChunks, bChunks)
failwithf
"""Fantomas is trying to format the input multiple times due to the detect of multiple defines.
There is a problem with merging all the code back together. Please raise an issue at https://github.com/fsprojects/fantomas/issues."""

If you know what combination returns fewer pieces then you can try and trace down where some trivia was not assigned or printed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant