From 54a1414500ee2f8f87647fc0ffe921498332446f Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 31 Jul 2023 07:47:26 -0300 Subject: 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. --- modules/gdscript/gdscript.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules/gdscript/gdscript.cpp') diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 22be26fdc1..4a7cd672bc 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2415,6 +2415,7 @@ void GDScriptLanguage::get_reserved_words(List *p_words) const { "return", "match", "while", + "when", // These keywords are not implemented currently, but reserved for (potential) future use. // We highlight them as keywords to make errors easier to understand. "trait", @@ -2448,6 +2449,7 @@ bool GDScriptLanguage::is_control_flow_keyword(String p_keyword) const { p_keyword == "match" || p_keyword == "pass" || p_keyword == "return" || + p_keyword == "when" || p_keyword == "while"; } -- cgit v1.2.3