Skip to content

Comments

Don't expose underscored signals#112770

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
KoBeWi:underscore_undercover
Nov 18, 2025
Merged

Don't expose underscored signals#112770
Repiteo merged 1 commit intogodotengine:masterfrom
KoBeWi:underscore_undercover

Conversation

@KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Nov 14, 2025

Inspired by https://github.com/godotengine/godot/actions/runs/19370312655/job/55424339576?pr=102963

This PR makes signals starting with underscore no longer appear in the documentation (including script documentation), nor autocompletion, making them consistent with methods. Interestingly, we don't have any such signal in core, but I know a few cases that were worked around with add_user_signal().

@Mickeon
Copy link
Member

Mickeon commented Nov 14, 2025

Even if we can work around it, this is also nice for user code, I suppose. I'd let this PR sit for a bit for potential consequences.

Copy link
Member

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, I do approve of it myself and you know it. We've been talking about this ad nauseam

Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good idea. Signals starting with an underscore are private/protected, like other things starting with an underscore, which also don't appear in the documentation and also don't show up in editor autocomplete.


if (signal_list.size()) {
for (const MethodInfo &mi : signal_list) {
if (mi.name.is_empty() || mi.name[0] == '_') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It dawned on me, how could a signal name possibly be empty?

Copy link
Member Author

@KoBeWi KoBeWi Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea, I copied it from methods

for (const MethodInfo &E : method_list) {
if (E.name.is_empty() || (E.name[0] == '_' && !(E.flags & METHOD_FLAG_VIRTUAL))) {

I think it's just safeguard, to avoid out of bounds crash on name[0].

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rrright, I guess it's faster than begins_with('_') (which probably doesn't even exist).

@Repiteo Repiteo modified the milestones: 4.x, 4.6 Nov 18, 2025
@Repiteo Repiteo merged commit f41c846 into godotengine:master Nov 18, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 18, 2025

Thanks!

@PiewieP
Copy link

PiewieP commented Jan 27, 2026

I'm testing Godot 4.6 and both signals and methods starting with an underscore appear in autocompletion. Am I missing something?
image

@KoBeWi
Copy link
Member Author

KoBeWi commented Jan 27, 2026

Looks like a bug. The signal is not added to the list by any method changed by this PR. Seems to affect only script signals. Open an issue.

@HolonProduction
Copy link
Member

I personally don't think we can just hide those completly. For C++ there is an asymmetry: the classes are used in GDScript but they are never written in GDScript. This means there is no situation were you would want to access something private.

For script members that's different. Not only the user code is written with autocompletion. Also the original code which works with private members is written with it. Hiding them without some sort of access resolution would make working with such classes easier, but it would make it annoying to develop classes with private members.

And well, access resolution isn't exactly straight forward, if we want to do that, we should have consensus on behaviour first.

Related:

#93210
#103768

@KoBeWi
Copy link
Member Author

KoBeWi commented Jan 27, 2026

Right, this is irrelevant for scripts. It's the same for methods and properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants