wordplaydev / wordplay

An accessible, language-inclusive programming language and IDE for creating interactive typography on the web.
Other
60 stars 22 forks source link

Space between function name and inputs leads to confusing errors #500

Closed amyjko closed 3 months ago

amyjko commented 3 months ago

What's the problem?

If someone inserts a space after the function name and before the inputs, there is a confusing error message:

Phrase ("hello")

This is interpreted as the structure Phrase followed by a block with the text hello.

Similarly:

Phrase("hello" place: Place (1m 2m))

This is interpreted as the input place being given the structure Place and then the next input being the block (1m 2m).

That pesky space can cause all kinds of confusion, but the space does have meaning.

What's the design idea?

Evaluate should check for a name token followed by Block not separated by a newline where there is a type error on both the name and the block and then generate a conflict indicating the likely error. The conflict should generate a resolution that proposes to remove the space to correct the error.

amyjko commented 3 months ago

Fixed with 1de29ab.

I decided to not change the way the language is parsed and instead provide a clearer message in this case.