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

Editor: Change "buffer exceeded: you probably have a missing closing bracket on a previous line" compile error message #2532

Open
edmundito opened this issue Sep 11, 2024 · 2 comments
Labels
ags3 related to ags3 (version with full backward compatibility) context: script compiler type: enhancement a suggestion or necessity to have something improved

Comments

@edmundito
Copy link
Contributor

Describe the problem
I ran into an issue where I made a mistake in my code and got the following error message:

GlobalScript.asc(X): Error (line X): buffer exceeded: you probably have a missing closing bracket on a previous line

So I looked around to see where I missed a bracket, and couldn't find anything. It was definitely nowhere near the previous line. I have my project on Git and reviewed the diff, seeing nothing unusual with the brackets. So I started commenting out some functions to see which one was stopping the compiler, and what I found is that I was missing a closing parenthesis and a semicolon in one of the functions. 🤦🏼

Anyway, the message above is too cryptic and too confident for what it knows.

Suggested change
This is a tricky one to solve because it needs to serve various potential errors and hint this. What can be done is:

  1. Identify different ways this error may occur (probably a closing whatever - } ) " ' ]) and confirm that the error appears when these are missing.
  2. Learn how other compilers communicate this in a friendlier way. Does it say "buffer exceeded?"
  3. Write a new message with a more vague suggestion. For example, ". This may be caused by a missing x, y, or z somewhere above this line."

Alternatively: The script parser somehow traces back to check where what is the first missing closing element and tells you the exact line, although this may be a more complex solution.

@ivan-mogilko
Copy link
Contributor

This problem is only related to the old compiler.
The new compiler in ags4 already reports these errors like:

NewScript1.asc(7): The '{' on this line isn't closed.

Normally a compiler should remember the last opening symbol and its position, and use this data in case of end of file.

@ivan-mogilko ivan-mogilko added ags3 related to ags3 (version with full backward compatibility) context: script compiler labels Sep 11, 2024
@fernewelten
Copy link
Contributor

fernewelten commented Sep 11, 2024

I assume that the (old) compiler is emitting the message?

A trick that I'm using in situations like that is to temporarily add a closer (e.g., a )) at the place where the error is reported. Then I use the editor functionality to find the opener (the () that corresponds to the added closer. Usually this puts me in a location that is nearer to the place where I goofed. (Try all the possible closers: ), ], }.)

As Ivan said, the new compiler should provide more helpful messages for mismatched opener/closer pairs - but as of now, the compiler is AGS 4 only.

@ivan-mogilko ivan-mogilko added type: bug unexpected/erroneous behavior in the existing functionality type: enhancement a suggestion or necessity to have something improved and removed type: bug unexpected/erroneous behavior in the existing functionality labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ags3 related to ags3 (version with full backward compatibility) context: script compiler type: enhancement a suggestion or necessity to have something improved
Projects
None yet
Development

No branches or pull requests

3 participants