Skip to content

Code with dictionary parse error breaks formatter #323

Description

@NicholasBolen

I have the following sample code which includes a parse error:

extends Control

# Error at (4, 6): Expected end of statement after variable declaration, found "{" instead.
var a: { "foo": "bar" } # Should be `a = {}`

# Ready function
func _ready() -> void:
	var prefix: String = "Value: "
	var count := 10

	for i in range(count):
		print(prefix, i)

Running the formatter gives the following result, unindenting all functions within the file:

extends Control

# Error at (4, 6): Expected end of statement after variable declaration, found "{" instead.
var a: { "foo": "bar" } # Should be `a = {}`

# Ready function
func _ready() -> void:
	var prefix: String = "Value: "
var count := 10

for i in range(count):
	print(prefix, i)

Formatter should probably not be able to run on a script containing parse errors to prevent this. Likely difficult to verify without godot running so this might be tricky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions