godotengine / godotengine/godot

Lambda requires extra line before End Of File

Open
#96,228 5 comments 2 reactions 0 assignees View on GitHub
bug confirmed discussion topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in Godot 4.3

### System information

Windows 11, Godot 4.3-stable

### Issue description

If I leave a lamda at the end of the file like this (line 12):
![image](https://github.com/user-attachments/assets/10fdfd4c-9913-424b-9eb2-6efe984c47d8)
The parser throws an error:
![image](https://github.com/user-attachments/assets/608b2b4c-e7c1-4393-bf61-f72f763f04a2)
However, this is fine (with extra line 13):
![image](https://github.com/user-attachments/assets/ea623cf4-f229-4942-8669-09271aa97876)

Ignore the fact that I'm doing stupid signal stuff above and causing infinite recursion, that's not a bug that's lack of sleep 💩

Pretty annoying as I frequently write lambdas like this and they happen to be at the EOF.

### Steps to reproduce

Open the MRP, issue.gd will not be parsed correctly.

### Minimal reproduction project (MRP)

[lambda-eof-mrp.zip](https://github.com/user-attachments/files/16784606/lambda-eof-mrp.zip)

Contributor guide

Open the contributing guide

Research direction

Open lambda-eof-mrp.zip and reproduce the parser error from issue.gd with the lambda at end of file. Trace the Godot parser behavior for the final lambda and verify that the reproduction parses without requiring an extra blank line at EOF.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.