From ff508dfede772ce9c08803faeb96d649fa9c0341 Mon Sep 17 00:00:00 2001 From: DualMatrix Date: Fri, 1 Feb 2019 17:09:41 +0100 Subject: Fixed Null appearing inside export variables with type hints and no default value The default value of the type is now used to initialise it. export(int) A Will now have A be 0 istead of Null even though it still showed as 0 before in the inspector, fixes #25357 --- modules/gdscript/gdscript_parser.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'modules/gdscript') diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index af189fdb7e..0eae734d93 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -4720,6 +4720,25 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { _set_error("Type-less export needs a constant expression assigned to infer type."); return; } + + if (member._export.type != Variant::NIL) { + IdentifierNode *id = alloc_node(); + id->name = member.identifier; + + ConstantNode *cn = alloc_node(); + + Variant::CallError ce; + cn->value = Variant::construct(member._export.type, NULL, 0, ce); + + OperatorNode *op = alloc_node(); + op->op = OperatorNode::OP_INIT_ASSIGN; + op->arguments.push_back(id); + op->arguments.push_back(cn); + + p_class->initializer->statements.push_back(op); + + member.initial_assignment = op; + } } if (autoexport && member.data_type.has_type) { -- cgit v1.2.3