Looks like the following code crashes the parser (at least in the latest Playground):
1. Two or more empty lines with no spaces:
```js
const a = 1;
const b = 2;
```
(note no spaces in lines between const)
Chrome:
TypeError: Cannot read property 'split' of null
at Object.embed$2 [as embed] (https://prettier.io/lib/index.js:1380:20)
at Object.printSubtree (https://prettier.io/lib/index.js:1646:1643)
at genericPrint$6 (https://prettier.io/lib/index.js:1652:21)
at https://prettier.io/lib/index.js:1648:206
at Object.printComments (https://prettier.io/lib/index.js:562:873)
at printGenerically (https://prettier.io/lib/index.js:1648:165)
at FastPath.call (https://prettier.io/lib/index.js:1540:261)
at processor (https://prettier.io/lib/index.js:1398:535)
at https://prettier.io/lib/index.js:1398:905
at FastPath.map (https://prettier.io/lib/index.js:1549:380)
FF:
embed$2@https://prettier.io/lib/index.js:1380:5
printSubtree@https://prettier.io/lib/index.js:1646:1627
genericPrint$6@https://prettier.io/lib/index.js:1652:9
printGenerically/res<@https://prettier.io/lib/index.js:1648:206
printComments@https://prettier.io/lib/index.js:562:873
printGenerically@https://prettier.io/lib/index.js:1648:156
call@https://prettier.io/lib/index.js:1540:261
processor@https://prettier.io/lib/index.js:1398:525
printChildren/<@https://prettier.io/lib/index.js:1398:905
map@https://prettier.io/lib/index.js:1549:380
printChildren@https://prettier.io/lib/index.js:1398:821
printRoot@https://prettier.io/lib/index.js:1398:18
genericPrint$3@https://prettier.io/lib/index.js:1381:1739
genericPrint$6@https://prettier.io/lib/index.js:1653:10
printGenerically/res<@https://prettier.io/lib/index.js:1648:206
printComments@https://prettier.io/lib/index.js:562:873
printGenerically@https://prettier.io/lib/index.js:1648:156
printAstToDoc@https://prettier.io/lib/index.js:1648:347
_formatWithCursor@https://prettier.io/lib/index.js:2366:1221
_format@https://prettier.io/lib/index.js:2367:239
format@https://prettier.io/lib/index.js:2386:277
formatCode@https://prettier.io/worker.js:130:12
self.onmessage@https://prettier.io/worker.js:80:19
Playground link
# Options (if any):
--parser=markdown
Expected behavior:
I'm not quite sure what the expected behaviour should be here. As an author of prettier-plugin-elm, I'd say it'd be great if the code block remained as is despite more than one empty line of code. That's because two empty lines are common in Elm. E.g.:
module Main exposing (..)
+
import Html exposing (text)
+
+
main =
text "Hello, World!"
In 1.11.0 the output was the following (see playground for #4035):
1. Two or more empty lines with no spaces:
```js
const a = 1;
```
const b = 2;
```
Still broken, but at least no crash.
Would it be feasible to leave two or more empty lines in code blocks (even without spaces) given that a plugin that formats that block may want so? If not, I'd have to get rid of double empty lines in Elm blocks, which some users might not like.
Looks like the following code crashes the parser (at least in the latest Playground):
(note no spaces in lines between
const)Chrome:
FF:
Playground link
# Options (if any): --parser=markdownExpected behavior:
I'm not quite sure what the expected behaviour should be here. As an author of
prettier-plugin-elm, I'd say it'd be great if the code block remained as is despite more than one empty line of code. That's because two empty lines are common in Elm. E.g.:In
1.11.0the output was the following (see playground for #4035):Still broken, but at least no crash.
Would it be feasible to leave two or more empty lines in code blocks (even without spaces) given that a plugin that formats that block may want so? If not, I'd have to get rid of double empty lines in Elm blocks, which some users might not like.