diff options
author | George Marques <george@gmarqu.es> | 2021-03-02 12:14:57 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 12:14:57 -0300 |
commit | 16e88f99e280f774d25966aec26aac834133c55f (patch) | |
tree | d54158363fdc93fbc75ab722b05ef9d582a44337 /modules/gdscript/gdscript_parser.cpp | |
parent | d86369b590dfc08802fd17675db0c19afee3e00f (diff) | |
parent | e4d5393ecf85e65809c124aa5a66571e0aa18168 (diff) |
Merge pull request #42029 from ThakeeNathees/export-type-infer-bug-fix
GDScript export array/dictionary type infer bug fix
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index b4f3bda1a8..08645d371c 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3168,11 +3168,16 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node push_error(R"(Cannot use "@export" annotation with variable without type or initializer, since type can't be inferred.)", p_annotation); return false; } - if (variable->initializer->type != Node::LITERAL) { + if (variable->initializer->type == Node::LITERAL) { + variable->export_info.type = static_cast<LiteralNode *>(variable->initializer)->value.get_type(); + } else if (variable->initializer->type == Node::ARRAY) { + variable->export_info.type = Variant::ARRAY; + } else if (variable->initializer->type == Node::DICTIONARY) { + variable->export_info.type = Variant::DICTIONARY; + } else { push_error(R"(To use "@export" annotation with type-less variable, the default value must be a literal.)", p_annotation); return false; } - variable->export_info.type = static_cast<LiteralNode *>(variable->initializer)->value.get_type(); } // else: Actual type will be set by the analyzer, which can infer the proper type. } |