erlfmt icon indicating copy to clipboard operation
erlfmt copied to clipboard

Print literal value instead of crashing on missing text annotation

Open richcarl opened this issue 3 years ago • 4 comments

This allows you to format syntax trees that have been synthesized outside erlfmt without forcing the caller to add "text" annotations for all literals in order to print them.

richcarl avatar Dec 07 '20 14:12 richcarl

Would it be possible to parse the AST and transform it to include these "text" annotations, before passing it back to erlfmt?

Or include a test with an explanation comment, so that we do not simplify this code later by accident?

awalterschulze avatar Dec 07 '20 14:12 awalterschulze

It is of course possible, just a bit annoying and expensive to do an extra pass rewriting the whole AST for this.

richcarl avatar Dec 07 '20 14:12 richcarl

If it is too much effort to have an extra pass over the AST, consider adding a test, with a comment that explains why this is necessary, to make sure we do not regress and remove this change when thinking we are cleaning things up.

awalterschulze avatar Dec 10 '20 13:12 awalterschulze

This is probably go to merge, just need a test. Do you want to add a test or maybe we can add one for you?

awalterschulze avatar Jan 18 '21 09:01 awalterschulze