From aa8e3e7b0fcb02c641b10e9748e3d9406c300884 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 6 Aug 2019 13:28:22 +0200 Subject: GDScript: add an optional message parameter to assert() Before this patch, assert() only took the condition to assert on: assert(item_data) Now, it can optionally take a string that will be printed upon failure: assert(item_data, item_name + " has no item data in ItemDatabase") This makes it easier to immediately see what the issue is by being able to write informative failure messages. Thanks to @wiped1 for sharing their patch, upon which this is based. Closes #17082 --- modules/gdscript/gdscript_parser.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/gdscript/gdscript_parser.h') diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 72aa819a8c..1e8193a63e 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -481,7 +481,12 @@ public: struct AssertNode : public Node { Node *condition; - AssertNode() { type = TYPE_ASSERT; } + Node *message; + AssertNode() : + condition(0), + message(0) { + type = TYPE_ASSERT; + } }; struct BreakpointNode : public Node { -- cgit v1.2.3