Expected indented block after function declaration in Godot 4
By Eduardo Orellana · Updated
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: setget in Godot 4: Expected end of statement after variable declaration, found "Identifier" instead
Reproduce it
A _ready() whose body was not indented.
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
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
indentedVerified 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](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_parser.cpp#L1956).
More on this: Does Godot use Python? No: GDScript looks like Python, and here is where it is not
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.
Related
- Used tab character for indentation instead of space
- Expected end of statement after variable declaration
- Every verified Godot 4 answer
- Unexpected identifier "…" in class body in Godot 4
- setget in Godot 4: Expected end of statement after variable declaration, found "Identifier" instead
- How to parse JSON in Godot 4: JSON.parse_string()
- The "tool" keyword was removed in Godot 4: use @tool
- Cannot infer the type of "…" variable because the value is "null" in Godot 4
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free