Skip to content

Commit

Permalink
Merge pull request #94327 from HolonProduction/underscore_identifier
Browse files Browse the repository at this point in the history
GDScript: Restore support for `Token::UNDERSCORE` in identifiers
  • Loading branch information
akien-mga committed Jul 17, 2024
2 parents a526445 + 06e732c commit c2b91e2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion modules/gdscript/gdscript_tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,9 @@ GDScriptTokenizer::Token GDScriptTokenizerText::potential_identifier() {

if (len == 1 && _peek(-1) == '_') {
// Lone underscore.
return make_token(Token::UNDERSCORE);
Token token = make_token(Token::UNDERSCORE);
token.literal = "_";
return token;
}

String name(_start, len);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends Node

func test() -> void:
var node1 := Node.new()
node1.name = "_"
var node2 := Node.new()
node2.name = "Child"
var node3 := Node.new()
node3.name = "Child"

add_child(node1)
node1.add_child(node2)
add_child(node3)

assert(get_node("_/Child") == $_/Child)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GDTEST_OK

0 comments on commit c2b91e2

Please sign in to comment.