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/gdscript_analyzer.cpp | |
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/gdscript_analyzer.cpp')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 55bb99133a..aac42b2c1f 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2219,6 +2219,10 @@ void GDScriptAnalyzer::resolve_match_branch(GDScriptParser::MatchBranchNode *p_m resolve_match_pattern(p_match_branch->patterns[i], p_match_test); } + if (p_match_branch->guard_body) { + resolve_suite(p_match_branch->guard_body); + } + resolve_suite(p_match_branch->block); decide_suite_type(p_match_branch, p_match_branch->block); |