Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading preprocessor error message with character literals, especially within dialogs #2609

Open
fernewelten opened this issue Dec 10, 2024 · 1 comment
Labels
context: script compiler type: bug unexpected/erroneous behavior in the existing functionality what: editor related to the game editor

Comments

@fernewelten
Copy link
Contributor

fernewelten commented Dec 10, 2024

Describe the bug

I hit on a big snag in a game that has > 20 dialogs: When I compiled (F7), the system complained Unterminated string in file __DialogScripts.asc, line 1384. I couldn't navigate to the error by double-clicking the message, so I was tasked with finding the rogue line in about 1500 lines of dialog that were distributed in 20 dialog "files". This was time consuming. (This aspect is reported in #2389.)

When I found the rogue line at long last, it turned out to be the following:

    EGO: I've died!

Note the indentation, which turns the line into an AGS statement instead of a dialog line. The system found the ' in ‘I've’ and complained about an Unterminated string.

It hadn't occurred to me at all that this might even be the problem: I had been looking for a missing ", not for a missing ' because the error message complained about a ‘string’.
So at the end of the day, I lost a lot of time and nerves in locating and hunting down the wrong problem in a big bunch of big "files".

How can we better help AGS programmers that are stuck in this kind of situation? The cryptic message Unterminated string isn't it IMHO.

AGS Version
AGS 4 branch, commit dfc68e2
Also happens within AGS 3.6.1

As far as I can see, the error message comes out of file preprocessor.cpp of the classic compiler, line 248 and/or file Preprocessor.cs of the Editor, line 391

To Reproduce
Steps to reproduce the behavior:

  • In a new AGS game that has the character cEgo
  • Create a new dialog
  • As the text of the dialog, enter:
@S
    EGO: I've
  • Compile (F7)
@ivan-mogilko ivan-mogilko added type: bug unexpected/erroneous behavior in the existing functionality what: editor related to the game editor context: script compiler labels Dec 10, 2024
@ericoporto
Copy link
Member

I think perhaps, adding line number as parameter in ConvertDialogScriptLine

private void ConvertDialogScriptLine(string thisLine, StringWriter sw, CompileMessages errors)

and then it could do a check that if a line starts with [ \t]+[a-zA-Z0-9]+: , meaning, any number of spaces, followed by any number of valid keyword characters followed by a : character, it should then throw a warning that "this line is probably not a script".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: script compiler type: bug unexpected/erroneous behavior in the existing functionality what: editor related to the game editor
Projects
None yet
Development

No branches or pull requests

3 participants