-
Notifications
You must be signed in to change notification settings - Fork 43
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
normalize whitespace in output across OCaml versions #91
Comments
That seems like opening a can of worms to me. i.e. we'd need to keep up with arbitrary formatting changes if we wanted to provide a stable output. Indeed, it might not just be whitespaces, but also parentheses and other things. It seems best to me to compare the files at the AST level, after having erased the locations. That's how |
It might be. In my test it was only whitespace. My assumption was that it should already be stable in non-whitespace output. Your point is that the AST is normalized by omp? Is there an easy way to do AST comparison with omp? |
|
I'm not sure that's true for past versions of OCaml. But even if it was, it's not written or tested anywhere. So I'd rather we promise nothing in omp rather than make promises we can't keep.
Nope. An AST is already normalised, otherwise it'd be a Concrete Syntax Tree. So essentially you let the parser do the normalisation. The locations are the only bit of information that capture the layout of the code. That's how
Agreed, and that could still work. For instance with:
Where |
I meant the potential differences in the AST across OCaml versions which are normalized/translated to the selected version by omp.
However, then the diff will also show the difference in whitespace if I currently don't have time for it, but I'd like to test what other pretty-printing differences there actually are, maybe by diffing the OCaml testsuite. Another idea: if omp can transform any AST to the newest OCaml version's one, it could copy its pretty-printing to offer current version pretty-printing for older versions. However, I don't know how much code would have to be pulled in for that. |
It's in |
I ran into some differences in whitespace across OCaml versions when testing a ppx rewriter.
For example OCaml 4.02-4.05 places no space after a comma in tuples but adds some trailing space in other places where OCaml >= 4.06 does not.
See here: vogler/ppx_distr_guards@2c94051
I normalize the output with sed and only then compare.
It would be nicer if the output was the same across versions.
I assume the pretty-printing is done by OCaml itself, but maybe omp could normalize it afterwards?
The text was updated successfully, but these errors were encountered: