YarnSpinnerTool / YarnSpinner

Yarn Spinner is a tool for building interactive dialogue in games!
https://yarnspinner.dev
MIT License
2.34k stars 201 forks source link

VSCode: Unexpected "T" while reading a return statement #388

Open andresmakesgames opened 1 month ago

andresmakesgames commented 1 month ago

What is the current behavior?

The Yarn Spinner VSCode extension reports a problem in my Yarn file, "Unexpected "T" while reading a return statement", when reading the command <<returnToMainMenu>>

Please provide the steps to reproduce, and if possible a minimal demo of the problem:

  1. I created a function in my application "returnToMainMenu".
  2. I defined it in my Functions.ysls.json file.
  3. I added the command to one of my Yarn files.
  4. The Yarn Spinner VSCode extension reports the problem noted above, with the 'T' in ToMainMenu underlined in red.

The only issue is the report in VSCode. This does not manifest in any problems during execution of the application - the custom function is still parsed and called as expected, and works fine.

What is the expected behavior?

No error message.

Please tell us about your environment:

Other information

I'm somewhat at a loss. I don't know VS Extensions well enough to diagnose!

desplesda commented 1 month ago

I think this is actually a bug in our parser! The parser is reading “return”, thinking it’s the return keyword, and getting confused from there. (This doesn’t happen with other keywords like if, because those are actually defined to include a space afterwards to prevent this issue.)

desplesda commented 1 month ago

Until a fix for this lands, you can temporarily work around this problem by changing the name of your command to not begin with the word “return”.

andresmakesgames commented 1 month ago

Yup, I figured it would be something like that. That makes sense to me! Thanks, Jon. It's not that annoying, and I'll just name the function "backToMainMenu".