Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

The formatted output is structurally different from the input with `--verify-structure` (false positive)

オープン
#366 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
tooling

調査の方向性

Start by locating the formatter’s parsing and line-breaking code, then trace how --verify-structure compares the input with formatted output. Reproduce the reported case with the two-line GDScript example and check whether backslash line continuations are treated consistently in both paths. Done means verification accepts the formatter’s output and unnecessary continuations are handled as described; the issue does not name specific files or tests.

索引モデルが issue の本文から書いたものです。

説明

I found a case where --verify-structure fails. I think it's a false positive.

$ gdscript-formatter example.gd --verify-structure
Formatting 1 file...Error: "Failed to format file example.gd: The formatted output is structurally different from the input. Please report this to the bug tracker with a copy of the input code: https://github.com/GDQuest/GDScript-formatter/issues/"

I stripped down the failing file to a minimal example with just the line that causes the issue:

func _process(_delta: float) -> void:
	unit.followTarget = unit.position.distance_to(unit.targetUnit.position) > Global.getAbility[abilityIdsPrioritized[0]].targetRange

Here is what it becomes after applying the formatting:

func _process(_delta: float) -> void:
	unit.followTarget = unit.position.distance_to(unit.targetUnit.position) > Global \
			.getAbility[abilityIdsPrioritized[0]] \
			.targetRange

I tested this formatted version and it still works.
The problem seems to be that the formatter is able to break long lines with \, but when parsing a file it does not recognize lines broken with \ as one line, so it thinks the file is now different.

That also means that the formatter does not put a line back together if it has unnecessary line breaks.
F.ex. if I do something weird like this (which is still the exact same code):

func _process(_delta: float) -> void:
	unit \
		.\
		followTarget = unit.position.distance_to(unit.targetUnit.position) > Global \
		.\
	getAbility[abilityIdsPrioritized[0]]\
	.targetRange

All the formatter does with it is add some indents. Ideally it should remove the unnecessary line breaks.

Suggestion

The formatter could as part of the format and --verify-structure operations start by replacing all \ line breaks with a whitespace.
Then it will be "blind" to whatever line breaks already exist and always consistently add the line breaks it deems necessary.
It could have an option to enable/disable.

主要言語
Rust
スター
468
フォーク
39
平均マージ
6時間 24分
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

GDQuest/GDScript-formatter のほかの issue

GDQuest/GDScript-formatter の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。