bootstrapworld / pyret-blocks

Block Language for the Pyret Programming Language
Apache License 2.0
3 stars 1 forks source link

Pretty-Printing funApp horizontally swallows a comma #16

Closed kaisucode closed 3 years ago

kaisucode commented 3 years ago

This line of code crashes the block editor when placed in beforehand as part of the example code in example/editor-example.js:

being(w.player.posn, radial-star(7, 1.5 * w.timer, 0.25 * w.timer, "solid", EXPLOSION-COLOR))

The console prints out Next token is ('NAME "radial-star") at 3:2-3:13, and then a message of TypeError: Cannot read property 'toString' of undefined on CodeMirrorBlocks.

However, the same line of code renders correctly with all the components and color schemes when manually inputted into the block editor.

schanzer commented 3 years ago

This actually looks like a pretty-printing issue with funApp. During a mode switch, CMB (1) parses the file, (2) pretty-prints it into a text representation that will be 1-to-1 with blocks, and (3) re-parses the pretty-printed code (see these lines).

This is a pretty good reduced test case: f(x, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")

This is the shortest-possible string that will trigger the pretty-printing rule for multiple lines. Removing one of the As means it can all fit on one line, and it parses fine.