GDScript: Allow empty parentheses for property getter declaration
This commit is contained in:
parent
c5291a3555
commit
668ba2d1a5
@ -1116,7 +1116,12 @@ void GDScriptParser::parse_property_getter(VariableNode *p_variable) {
|
||||
case VariableNode::PROP_INLINE: {
|
||||
FunctionNode *function = alloc_node<FunctionNode>();
|
||||
|
||||
consume(GDScriptTokenizer::Token::COLON, R"(Expected ":" after "get".)");
|
||||
if (match(GDScriptTokenizer::Token::PARENTHESIS_OPEN)) {
|
||||
consume(GDScriptTokenizer::Token::PARENTHESIS_CLOSE, R"*(Expected ")" after "get(".)*");
|
||||
consume(GDScriptTokenizer::Token::COLON, R"*(Expected ":" after "get()".)*");
|
||||
} else {
|
||||
consume(GDScriptTokenizer::Token::COLON, R"(Expected ":" or "(" after "get".)");
|
||||
}
|
||||
|
||||
IdentifierNode *identifier = alloc_node<IdentifierNode>();
|
||||
complete_extents(identifier);
|
||||
@ -1264,8 +1269,7 @@ GDScriptParser::EnumNode *GDScriptParser::parse_enum(bool p_is_static) {
|
||||
EnumNode *enum_node = alloc_node<EnumNode>();
|
||||
bool named = false;
|
||||
|
||||
if (check(GDScriptTokenizer::Token::IDENTIFIER)) {
|
||||
advance();
|
||||
if (match(GDScriptTokenizer::Token::IDENTIFIER)) {
|
||||
enum_node->identifier = parse_identifier();
|
||||
named = true;
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ var property:
|
||||
set(value):
|
||||
_backing = value - 1000
|
||||
|
||||
var property_2:
|
||||
get(): # Allow parentheses.
|
||||
return 123
|
||||
|
||||
func test():
|
||||
print("Not using self:")
|
||||
@ -35,3 +38,5 @@ func test():
|
||||
self.property = 5000
|
||||
print(self.property)
|
||||
print(self._backing)
|
||||
|
||||
print(property_2)
|
||||
|
@ -17,3 +17,4 @@ Using self:
|
||||
-50
|
||||
5000
|
||||
4000
|
||||
123
|
||||
|
Loading…
Reference in New Issue
Block a user