Merge pull request #27876 from vnen/gdscript-no-builtin-name

Don't allow built-in scripts to use class_name
This commit is contained in:
Rémi Verschelde 2019-04-11 09:43:23 +02:00 committed by GitHub
commit 10c7742df3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3500,6 +3500,10 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
_set_error("'class_name' is only valid for the main class namespace."); _set_error("'class_name' is only valid for the main class namespace.");
return; return;
} }
if (self_path.empty()) {
_set_error("'class_name' not allowed in built-in scripts.");
return;
}
if (tokenizer->get_token(1) != GDScriptTokenizer::TK_IDENTIFIER) { if (tokenizer->get_token(1) != GDScriptTokenizer::TK_IDENTIFIER) {
_set_error("'class_name' syntax: 'class_name <UniqueName>'"); _set_error("'class_name' syntax: 'class_name <UniqueName>'");