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: {
|
case VariableNode::PROP_INLINE: {
|
||||||
FunctionNode *function = alloc_node<FunctionNode>();
|
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>();
|
IdentifierNode *identifier = alloc_node<IdentifierNode>();
|
||||||
complete_extents(identifier);
|
complete_extents(identifier);
|
||||||
@ -1264,8 +1269,7 @@ GDScriptParser::EnumNode *GDScriptParser::parse_enum(bool p_is_static) {
|
|||||||
EnumNode *enum_node = alloc_node<EnumNode>();
|
EnumNode *enum_node = alloc_node<EnumNode>();
|
||||||
bool named = false;
|
bool named = false;
|
||||||
|
|
||||||
if (check(GDScriptTokenizer::Token::IDENTIFIER)) {
|
if (match(GDScriptTokenizer::Token::IDENTIFIER)) {
|
||||||
advance();
|
|
||||||
enum_node->identifier = parse_identifier();
|
enum_node->identifier = parse_identifier();
|
||||||
named = true;
|
named = true;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@ var property:
|
|||||||
set(value):
|
set(value):
|
||||||
_backing = value - 1000
|
_backing = value - 1000
|
||||||
|
|
||||||
|
var property_2:
|
||||||
|
get(): # Allow parentheses.
|
||||||
|
return 123
|
||||||
|
|
||||||
func test():
|
func test():
|
||||||
print("Not using self:")
|
print("Not using self:")
|
||||||
@ -35,3 +38,5 @@ func test():
|
|||||||
self.property = 5000
|
self.property = 5000
|
||||||
print(self.property)
|
print(self.property)
|
||||||
print(self._backing)
|
print(self._backing)
|
||||||
|
|
||||||
|
print(property_2)
|
||||||
|
@ -17,3 +17,4 @@ Using self:
|
|||||||
-50
|
-50
|
||||||
5000
|
5000
|
||||||
4000
|
4000
|
||||||
|
123
|
||||||
|
Loading…
Reference in New Issue
Block a user