Tested on gdscript-formatter 0.21.0 (Pre-release 0.21.0-beta, published 2026-07-12), Linux x86_64. Upstream main checked up to 248fa13b (2026-07-12 09:20 UTC) — no fix commit found.
Impact (critical — parse error)
Places in at statement top. GDScript rejects this — running the formatted file yields Parse Error: Expected statement, found "in" instead and the whole script fails to load. Consumers that reference the class (via preload / class_name) then cascade into "Identifier X not declared" errors.
Trigger
return <expr> in [ ... ] where the list already spans multiple lines. Line-length wrapping decides to break before in and drops the operator + [ to the next line.
Repro
Input (bug.gd):
static func is_known_effect_kind(name: StringName) -> bool:
return name in [
&"harvest_multiplier", &"energy_bonus", &"free_return_trip",
&"all_weather_roads", &"fertilizer_next_day_bloom", &"bloom_all_nodes",
&"bloom_bonus_boost", &"restore_hunger", &"restore_sleepiness",
]
Command:
gdscript-formatter --stdout --reorder-code bug.gd
Actual output
static func is_known_effect_kind(name: StringName) -> bool:
return name
in [
&"harvest_multiplier",
&"energy_bonus",
&"free_return_trip",
&"all_weather_roads",
&"fertilizer_next_day_bloom",
&"bloom_all_nodes",
&"bloom_bonus_boost",
&"restore_hunger",
&"restore_sleepiness",
]
Expected
Keep return name in [ on one line, wrap only the list elements. Never place in at statement top.
Tested on
gdscript-formatter 0.21.0(Pre-release0.21.0-beta, published 2026-07-12), Linux x86_64. Upstreammainchecked up to248fa13b(2026-07-12 09:20 UTC) — no fix commit found.Impact (critical — parse error)
Places
inat statement top. GDScript rejects this — running the formatted file yieldsParse Error: Expected statement, found "in" insteadand the whole script fails to load. Consumers that reference the class (viapreload/class_name) then cascade into "Identifier X not declared" errors.Trigger
return <expr> in [ ... ]where the list already spans multiple lines. Line-length wrapping decides to break beforeinand drops the operator +[to the next line.Repro
Input (
bug.gd):Command:
Actual output
Expected
Keep
return name in [on one line, wrap only the list elements. Never placeinat statement top.