Skip to content

Commit

Permalink
fix gdscript 2.0 parsing error when no newline at EOF
Browse files Browse the repository at this point in the history
GDScript 2.0 can have parsing errors if the script does not end with a newline
  • Loading branch information
nikitalita committed Jan 8, 2025
1 parent 29f3c04 commit 982f059
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bytecode/bytecode_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,11 @@ Error GDScriptDecomp::decompile_buffer(Vector<uint8_t> p_buffer) {
script_text += line;
}

// GDScript 2.0 can have parsing errors if the script does not end with a newline
if (bytecode_version >= GDSCRIPT_2_0_VERSION && !script_text.ends_with("\n")) {
script_text += "\n";
}

if (script_text == String()) {
if (identifiers.size() == 0 && constants.size() == 0 && tokens.size() == 0) {
return OK;
Expand Down

0 comments on commit 982f059

Please sign in to comment.