diff options
author | William Deurwaarder <william.git@xs4all.nl> | 2021-08-25 00:33:17 +0200 |
---|---|---|
committer | William Deurwaarder <william.git@xs4all.nl> | 2021-08-28 17:29:35 +0200 |
commit | e77338978f9f4186d136773a06a4b5c0177780ee (patch) | |
tree | d638c5b117c5c62e545c738f6edb588326d2f152 /modules/gdscript | |
parent | dcf2d09231c03c444cf5374b4d250f327f1333e4 (diff) |
Print error message when await is not followed by signal or coroutine
When await was not followed by a signal or coroutine the GDScript parser would
crash.
This fix will check if await is followed by a signal or coroutine in case that
isn't true (element == nullptr) then an error message is printed.
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 029e30080b..d202bd4420 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -2380,7 +2380,11 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_assignment(ExpressionNode GDScriptParser::ExpressionNode *GDScriptParser::parse_await(ExpressionNode *p_previous_operand, bool p_can_assign) { AwaitNode *await = alloc_node<AwaitNode>(); - await->to_await = parse_precedence(PREC_AWAIT, false); + ExpressionNode *element = parse_precedence(PREC_AWAIT, false); + if (element == nullptr) { + push_error(R"(Expected signal or coroutine after "await".)"); + } + await->to_await = element; current_function->is_coroutine = true; |