Expected indented block after function declaration in Godot 4
Every func needs a body indented one level under it, and this one has none. func _ready(): followed by an unindented line fails to parse with Expected indented block after function declaration. Indent the body under the func line, or write pass for a function that does nothing yet.
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 the colon of a function declaration the parser expects a new line that is indented deeper than the func line. A line at the same depth, or the end of the file, means the function has no body.
The same rule names other blocks: Expected indented block after "if" block, after "for" block, after class declaration.
More on this: Does Godot use Python? No: GDScript looks like Python, and here is where it is not
Reproduce it
A _ready() whose body was not indented.
More on this: Expected end of statement after variable declaration, found "Identifier" instead: setget in Godot 4
extends Node
func _ready() -> void:
print("no indent")
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Expected indented block after function declaration.
at: GDScript::reload (res://answers/expected-indented-block-after-function-declaration/repro.gd:3)
ERROR: Failed to load script "res://answers/expected-indented-block-after-function-declaration/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
Indent the body, and use pass for an empty function.
extends Node
func _ready() -> void:
print("indented")
func _on_timeout() -> void:
pass
What the fixed script prints
More on this: Trying to return a value of type "…" from a function whose return type is "…" in Godot 4
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
indentedRun 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.
More on this: Too few arguments for "…()" call. Expected at least N but received M in Godot 4
My Godot 4 project prints this error: "Parse Error: Expected indented block after function declaration.". Find where it comes from and fix it. Every func needs a body indented one level under it, and this one has none. func _ready(): followed by an unindented line fails to parse with Expected indented block after function declaration. Indent the body under the func line, or write pass for a function that does nothing yet. 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 1956, the message.
Questions
- What is pass for?
- It is a statement that does nothing, for a block that must exist but has no code yet.
- Why does the error point at the func line?
- The parser reports where the block it expected should have started, which is the line with the colon.
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free