Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable declaration in typed Multiline Lambda #327

Closed
plink-plonk-will opened this issue Sep 29, 2024 · 2 comments
Closed

Variable declaration in typed Multiline Lambda #327

plink-plonk-will opened this issue Sep 29, 2024 · 2 comments
Labels
bug Something isn't working parser

Comments

@plink-plonk-will
Copy link
Contributor

Hi! I've noticed an issue with lambda's with statically typed return type:

Creating an untyped lambda like this works:

new_button.pressed.connect(
    func():
        var test := ""
        _game_flow.ref.request_transition(menu[button_name].transition, menu[button_name].data)
)

Creating a typed lambda without a variable declaration works:

new_button.pressed.connect(
    func() -> void:
        _game_flow.ref.request_transition(menu[button_name].transition, menu[button_name].data)
)

But creating a typed lambda containing a variable declaration does not:

new_button.pressed.connect(
    func() -> void:
        var test := ""
        _game_flow.ref.request_transition(menu[button_name].transition, menu[button_name].data)
)

Failure is:

					_game_flow.ref.request_transition(
                                        ^

Unexpected token Token('TYPE_HINT', '_game_flow.ref.request_transition') at line 52, column 6.
Expected one of: 
	* IN
	* "-="
	* ">>="
	* IS
	* ">="
	* VBAR
	* MORETHAN
	* "/="
	* LESSTHAN
	* "*="
	* "**="
	* AND
	* COMMA
	* PERCENT
	* "%="
	* "&&"
	* EQUAL
	* AS
	* "&="
	* "||"
	* PLUS
	* RPAR
	* "+="
	* AMPERSAND
	* "!="
	* SEMICOLON
	* "=="
	* ">>"
	* NOT
	* "<="
	* OR
	* "<<="
	* SLASH
	* IF
	* CIRCUMFLEX
	* STAR
	* "<<"
	* "**"
	* "|="
	* "is not"
	* "^="
	* DOT
	* MINUS
	* LSQB
Previous tokens: [Token('_NL', '\n\t\t\t\t\t')]
@Scony Scony added bug Something isn't working parser labels Sep 29, 2024
@Scony Scony closed this as completed in 4b628ed Sep 29, 2024
@Scony
Copy link
Owner

Scony commented Sep 29, 2024

Hi, thank you for reporting.

I've confirmed this is a bug within lexer that produces such a strange error on the high level.

I've quick-fixed the issue on master. I'll prepare more generic fix soon, but you should be already able to proceed.

@plink-plonk-will
Copy link
Contributor Author

That was fast! Thank you!

Scony added a commit that referenced this issue Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser
Projects
None yet
Development

No branches or pull requests

2 participants