diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-02-12 12:01:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-12 12:01:22 +0100 |
commit | e40395669cf277e948e1a520a6584ce0deafd91a (patch) | |
tree | 0e57ac22b225d467531d093a7f38fd9ade16ab67 /modules | |
parent | 279bfb3503ff034615d38df6405b7ebd7751ce95 (diff) | |
parent | ff508dfede772ce9c08803faeb96d649fa9c0341 (diff) |
Merge pull request #25550 from DualMatrix/fix-25357
Fixed Null appearing inside export variables with type hints and no default value
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 7334e8a8cc..c1a25dec1e 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -4724,6 +4724,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<IdentifierNode>(); + id->name = member.identifier; + + ConstantNode *cn = alloc_node<ConstantNode>(); + + Variant::CallError ce; + cn->value = Variant::construct(member._export.type, NULL, 0, ce); + + OperatorNode *op = alloc_node<OperatorNode>(); + 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) { |