diff options
author | George Marques <george@gmarqu.es> | 2023-07-31 07:47:26 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2023-09-27 11:25:25 -0300 |
commit | 54a1414500ee2f8f87647fc0ffe921498332446f (patch) | |
tree | 693245f3f7289fc375831907c55d31d55b9f0137 /modules/gdscript/tests/scripts/parser/errors | |
parent | ec62b8a3ee1d731387a440b4d2abb7961aa28322 (diff) | |
download | redot-engine-54a1414500ee2f8f87647fc0ffe921498332446f.tar.gz |
GDScript: Implement pattern guards for match statement
Within a match statement, it is now possible to add guards in each
branch:
var a = 0
match a:
0 when false: print("does not run")
0 when true: print("but this does")
This allows more complex logic for deciding which branch to take.
Diffstat (limited to 'modules/gdscript/tests/scripts/parser/errors')
-rw-r--r-- | modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd | 5 | ||||
-rw-r--r-- | modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd new file mode 100644 index 0000000000..d88b4a37c4 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.gd @@ -0,0 +1,5 @@ +func test(): + var a = 0 + match a: + 0 when a = 1: + print("assignment not allowed on pattern guard") diff --git a/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out new file mode 100644 index 0000000000..e8f9130706 --- /dev/null +++ b/modules/gdscript/tests/scripts/parser/errors/match_guard_with_assignment.out @@ -0,0 +1,2 @@ +GDTEST_PARSER_ERROR +Assignment is not allowed inside an expression. |