hedyorg / hedy

Hedy is a gradual programming language to teach children programming. Gradual languages use different language levels, where each level adds new concepts and syntactic complexity. At the end of the Hedy level sequence, kids master a subset of syntactically valid Python.
https://www.hedy.org
European Union Public License 1.2
1.3k stars 285 forks source link

[BUG] Unhelpful error message for `play C4 C4` #5595

Open zellyn opened 3 months ago

zellyn commented 3 months ago

Describe the bug In an attempt to play the first few notes of "Twinkle, twinkle little star", I entered:

play C4 C4
play G4 G4

The error message was misleading/unhelpful:

We can't run your program.

The code you entered is not valid Hedy code. There is a mistake on line 1, at position 1. You typed play, but that is not allowed.

screenshot

image

I'm a professional programmer, exploring Hedy after listening to the latest CoRecursive podcast: if this fix would be within the bounds of the existing error message generation, feel free to just point me in the right direction and I'll send a PR. I love what you're doing!

Felienne commented 3 months ago

Hi @zellyn!

Thanks for the message and the kind words! Music is a bit new so the errors are not as well developed as they could be. What you see here is a parse error, but what could do to make this better is to add an error production, not sure how familiar you are with compiler/parser technology, this might not be enough info for you?

The idea is to add an extra rule to catch this and to present an error based on that.

Here is a PR that also adds a new error production, maybe that helps as an inspiration: https://github.com/hedyorg/hedy/pull/5177/files#diff-3de13d718733aaa612bf35f9750f41c325f7be6f1df0030b4ad029406ca0276b

If not, do feel free to reach out!