Scony / godot-gdscript-toolkit

Independent set of GDScript tools - parser, linter, formatter, and more
MIT License
1.01k stars 68 forks source link

GDParse (and things that depend on it) Crash when a lambda contains a loop #316

Closed IntangibleMatter closed 2 months ago

IntangibleMatter commented 2 months ago

The following code block makes any script crash GDToolkit.

var myfunc := func() -> void:
    for i in 10:
        print("test")

I believe this is likely due to it expecting lambdas to not require newlines, though loops do, and crashing when it encounters it.

When running gdformat <script> --verbose the following is output to the console:

gdformat-test.gd:

var myfunc := func() -> void:
                             ^

Unexpected token Token('_NL', '\n\t') at line 3, column 30.
Expected one of: 
        * BIN
        * NAME
        * BANG
        * LONG_STRING
        * NOT
        * TILDE
        * CIRCUMFLEX
        * MINUS
        * PLUS
        * PERCENT
        * LPAR
        * HEX
        * FUNC
        * PASS
        * AWAIT
        * RETURN
        * LBRACE
        * SET
        * REGULAR_RSTRING
        * GET
        * DOLLAR
        * REGULAR_STRING
        * LSQB
        * VAR
        * LONG_RSTRING
        * NUMBER
        * AMPERSAND

Running on Linux Pop!_OS 22.04, installed via pipx, Godot 4.3-rc3

Scony commented 2 months ago

Duplicate of https://github.com/Scony/godot-gdscript-toolkit/issues/191 it's currently WIP