From 34dc689ad40980869d2a2d08b68ae6b9ec36d498 Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 31 Aug 2020 10:01:45 -0300 Subject: GDScript: Allow "self" to be used in class level --- modules/gdscript/gdscript_parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gdscript/gdscript_parser.cpp') diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 03da5e926b..0a4ca01a32 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1941,8 +1941,8 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_literal(ExpressionNode *p_ } GDScriptParser::ExpressionNode *GDScriptParser::parse_self(ExpressionNode *p_previous_operand, bool p_can_assign) { - if (!current_function || current_function->is_static) { - push_error(R"(Cannot use "self" outside a non-static function.)"); + if (current_function && current_function->is_static) { + push_error(R"(Cannot use "self" inside a static function.)"); } SelfNode *self = alloc_node(); self->current_class = current_class; -- cgit v1.2.3 From edb4caf24e29d2e0836b5d86c33ba4c32cc6afd1 Mon Sep 17 00:00:00 2001 From: George Marques Date: Mon, 31 Aug 2020 10:27:11 -0300 Subject: GDScript: Allow "extends" to be used inside inner class --- modules/gdscript/gdscript_parser.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'modules/gdscript/gdscript_parser.cpp') diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 0a4ca01a32..4761506381 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -586,6 +586,14 @@ GDScriptParser::ClassNode *GDScriptParser::parse_class() { return n_class; } + if (match(GDScriptTokenizer::Token::EXTENDS)) { + if (n_class->extends_used) { + push_error(R"(Cannot use "extends" more than once in the same class.)"); + } + parse_extends(); + end_statement("superclass"); + } + parse_class_body(); consume(GDScriptTokenizer::Token::DEDENT, R"(Missing unindent at the end of the class body.)"); -- cgit v1.2.3