Print a line break after raw code that ends with a line comment
Why
A %raw expression is printed on the same line as what follows it, so a line comment at its end commented that out: the parenthesis that closes raw code, which gave a syntax error, or the rest of an expression after a raw literal, which gave another value without an error. A line break at the end of the code does not help, since E.raw_js_code trims it. Js_dump now prints a line break after the code when Classify_function.ends_in_line_comment finds that a line comment runs to its end: its last line holds "//", and the code followed by ) does not parse.
modifiedJS raw code ending with a line comment
let add = (a, b) => a + blet f: int => int = %raw(`x => x + 1 // add one`)let two = add(%raw(`1 // one`), 1)
js
Review
- Why parse the code? A "//" on the last line may be in a string, a template or a regular expression, as in the string literal
"http://example.com", which is printed as before. Only code whose last line holds "//" is parsed, and code that the Flow parser rejects gets the line break. - What about
%%raw? A raw statement is already printed on lines of its own. - Which checked-in outputs change? None.