summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_parser.cpp
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2019-02-26 14:58:39 +0200
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2019-02-26 14:58:39 +0200
commitdb7864c1fd852416f2ada7038bfbf71813904174 (patch)
tree39578a8f441295c3682664a807a07289a0847b34 /modules/gdscript/gdscript_parser.cpp
parent22ee7ba4f083fdfab1c177fcd8d921736b5a91ca (diff)
Fix GDScript exports having the wrong type of default value by converting it
Also, initialize elements of PoolArrays when resizing them in the editor. Fixes #26066.
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r--modules/gdscript/gdscript_parser.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index adbd7e4e04..5ebf68177d 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -4691,6 +4691,16 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
ConstantNode *cn = static_cast<ConstantNode *>(subexpr);
if (cn->value.get_type() != Variant::NIL) {
+ if (member._export.type != Variant::NIL && cn->value.get_type() != member._export.type) {
+ if (Variant::can_convert(cn->value.get_type(), member._export.type)) {
+ Variant::CallError err;
+ const Variant *args = &cn->value;
+ cn->value = Variant::construct(member._export.type, &args, 1, err);
+ } else {
+ _set_error("Cannot convert the provided value to the export type.");
+ return;
+ }
+ }
member.default_value = cn->value;
}
}