parent
7d972b8c67
commit
ebade0e454
|
@ -1215,7 +1215,10 @@ void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant
|
|||
void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) {
|
||||
reduce_expression(p_assert->condition);
|
||||
if (p_assert->message != nullptr) {
|
||||
reduce_literal(p_assert->message);
|
||||
reduce_expression(p_assert->message);
|
||||
if (!p_assert->message->is_constant || p_assert->message->reduced_value.get_type() != Variant::STRING) {
|
||||
push_error(R"(Expected constant string for assert error message.)", p_assert->message);
|
||||
}
|
||||
}
|
||||
|
||||
p_assert->set_datatype(p_assert->condition->get_datatype());
|
||||
|
|
|
@ -1501,12 +1501,9 @@ GDScriptParser::AssertNode *GDScriptParser::parse_assert() {
|
|||
|
||||
if (match(GDScriptTokenizer::Token::COMMA)) {
|
||||
// Error message.
|
||||
if (consume(GDScriptTokenizer::Token::LITERAL, R"(Expected error message for assert after ",".)")) {
|
||||
assert->message = parse_literal();
|
||||
if (assert->message->value.get_type() != Variant::STRING) {
|
||||
push_error(R"(Expected string for assert error message.)");
|
||||
}
|
||||
} else {
|
||||
assert->message = parse_expression(false);
|
||||
if (assert->message == nullptr) {
|
||||
push_error(R"(Expected error message for assert after ",".)");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ public:
|
|||
|
||||
struct AssertNode : public Node {
|
||||
ExpressionNode *condition = nullptr;
|
||||
LiteralNode *message = nullptr;
|
||||
ExpressionNode *message = nullptr;
|
||||
|
||||
AssertNode() {
|
||||
type = ASSERT;
|
||||
|
|
Loading…
Reference in New Issue