-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clearer error messages when using set/get incorrectly.
It's quite easy for users to forget to use the colon before their setters and getters, but in this situation error messages are unclear about the real nature of the problem. This commit adds a check for malformed set/get statements and provides error messages containing more direct guidance to users. Closes #91216
- Loading branch information
1 parent
02deedc
commit 17de35e
Showing
5 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
modules/gdscript/tests/scripts/parser/errors/missing_colon_setget_indent.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#GDTEST_PARSER_ERROR | ||
|
||
var property | ||
get(): | ||
return 0 | ||
|
||
func test(): | ||
pass |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/parser/errors/missing_colon_setget_indent.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_PARSER_ERROR | ||
Expected ":" at end of variable declaration when using "set" or "get" |
9 changes: 9 additions & 0 deletions
9
modules/gdscript/tests/scripts/parser/errors/missing_colon_setget_inline.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#GDTEST_PARSER_ERROR | ||
|
||
var property get = get_property | ||
|
||
func test(): | ||
pass | ||
|
||
func get_property(): | ||
return 0 |
2 changes: 2 additions & 0 deletions
2
modules/gdscript/tests/scripts/parser/errors/missing_colon_setget_inline.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
GDTEST_PARSER_ERROR | ||
Expected ":" before "get". |