-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Improve misleading GDScript parser error #99887
base: master
Are you sure you want to change the base?
Conversation
1b8b688
to
52110ab
Compare
modules/gdscript/gdscript_parser.cpp
Outdated
advance(); | ||
push_error(vformat(R"(Unexpected "%s" in class body.)", previous.source)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the token source code in the error message is debatable, since tokens can be multiline or unreadable (LITERAL
, NEWLINE
, INDENT
, DEDENT
). I think we should use something like:
const String token_name = previous.is_identifier() ? previous.get_identifier() : previous.get_name();
Or maybe add a new method to GDScriptTokenizer::Token
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this change and made a new test to verify it's on the proper line.
This parser error was misleading. Fixes: 1. Now points at correct line 2. Now prints out the raw token source (e.g. "variable_name" instead of "<Identifier>")
52110ab
to
b04497c
Compare
Verified it fixes #96792 |
This parser error was misleading.
Fixes:
====
With Change:
Without Change (misleading):