diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-02-27 00:16:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-27 00:16:02 +0100 |
commit | 28a57c2c291366980bad267e194d192e02105c6d (patch) | |
tree | dac2a1e1ffd9c450a7bd894b760522131561878e /modules | |
parent | 01a3dd389cc84b9a059fe8e45f2d51ce1d69eebc (diff) | |
parent | db7864c1fd852416f2ada7038bfbf71813904174 (diff) |
Merge pull request #26304 from bojidar-bg/26066-fix-exported-poolarray
Fix GDScript exports having the wrong type of default value by converting it
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 10 |
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; } } |