Skip to content

Non-parenthesized lambda can lead to a parse error when not parenthesized or followed by other arguments #292

Description

@NathanLovato

This is a follow-up to issue #287:

@NathanLovato
New findings, probably related to this again:

Input:

func _test() -> void:
    var test: String = ", ".join([].map(func(it: String) -> String: return it))

Command:
gdscript-formatter --use-spaces --max-line-length 10 .\test.gd
--max-line-length 10 is only to simulate a long expression, not necessary.

Output

func _test() -> void:
    var test: String = ", ".join(
        [].map(
            func(
                it: String
            ) -> String:
                return it
        )
    )
Image

I've a really big codebase that contains all sort of things including addons. I believe this is the only remaining code that breaks after i use the formatter.

Originally posted by @portlek in #287

This is a limitation of the GDScript parser that we need to work around. It wants whatever comes after a multi-line lambda to be indented at the same level.

Need to decide on what to do with lambdas in parenthesized expressions, if to give them snug parentheses, or trailing coma, or always indent the following closing parentheses.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions