Expected end of statement after variable declaration, found "Identifier" instead in Godot 4
A statement ended and something else followed it on the same line. var a = 5 print(a) fails to parse with Expected end of statement after variable declaration, found "Identifier" instead. Put each statement on its own line, or separate them with a semicolon.
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
After a complete statement the parser expects a newline or a semicolon. When it finds another token instead, it reports what kind of statement had just ended and what token came next.
The context changes with the statement: after expression, after return statement, after "pass". A missing operator between two values, such as speed delta, gives the same message after expression.
More on this: Unexpected identifier "…" in class body in Godot 4
Reproduce it
A declaration and a print on one line.
More on this: Expected end of statement after variable declaration, found "Identifier" instead: setget in Godot 4
extends Node
func _ready() -> void:
var a = 5 print(a)
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Expected end of statement after variable declaration, found "Identifier" instead.
at: GDScript::reload (res://answers/expected-end-of-statement-after-variable-declaration/repro.gd:4)
ERROR: Failed to load script "res://answers/expected-end-of-statement-after-variable-declaration/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
One statement per line, or a semicolon between them.
extends Node
func _ready() -> void:
var a = 5
print(a)
var b = 6; print(b)
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
5
6Run this fix with your agent
Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.
My Godot 4 project prints this error: "Parse Error: Expected end of statement after variable declaration, found "Identifier" instead.". Find where it comes from and fix it. A statement ended and something else followed it on the same line. var a = 5 print(a) fails to parse with Expected end of statement after variable declaration, found "Identifier" instead. Put each statement on its own line, or separate them with a semicolon. Then run the game headless and check that Godot's output no longer shows it.Verified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: gdscript_parser.cpp line 695, the message, gdscript_parser.cpp line 1296, the variable declaration context.
Questions
- Are semicolons allowed in GDScript?
- Yes, as a separator between statements on one line. They are optional at the end of a line, and Godot's style guide leaves them out.
- What does found "Identifier" mean?
- The next token was a name, here print. Other values name other tokens, such as found "(" or found "Literal".
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free