Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#366 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
rust
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
468
Forks
39
Merge medio
6 h 24 min
PR fusionados (30 d)
3

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de GDQuest/GDScript-formatter

Todos los issues de GDQuest/GDScript-formatter

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.