sourcepawn icon indicating copy to clipboard operation
sourcepawn copied to clipboard

No warning for unused enum struct fields and methods

Open dysphie opened this issue 3 years ago • 2 comments

Code

enum struct Thing
{
	bool a;
	bool b;

	void DoThing() 
	{
		
	}
}

public void OnPluginStart()
{
	Thing t;
	t.a = true;
}

produces no warning for unused symbols b and DoThing. Tested in spcomp 1.11.0.6846

dysphie avatar Feb 14 '22 00:02 dysphie

I don't see us adding this warning. We don't check for unused types, and we don't check for unused properties/nethods of types.

dvander avatar Feb 14 '22 03:02 dvander

Fair enough. My reasoning was that the compiler already checks for unused global vars and methodmap functions, and ES are used by developers in a similar fashion. I can't think of a scenario where one would want to declare ES properties/methods and never use them. Whenever I do this, it's by mistake. Even though they're just arrays under the hood, their declaration is more explicit and they can't be sanely passed via natives, so if the properties/methods aren't used locally, they're just dead code/memory. (unless I'm missing a use case where this isn't true)

dysphie avatar Feb 14 '22 04:02 dysphie