Syntax highlighting, code completion, auto indentation fail when method named void.
Let me preface this by saying I know that one's best practices should never involve naming a method "void" given its status as a return type, but sometimes things happen. Despite that, Salesforce does technically allow you to name your method that, and it deploys fine.
When these things happen, syntax highlighting, code completion and auto indentation get thrown off for the entire file containing a method named "void". See the screenshot below for a bit more info regarding the highlighting aspect of it.
Comments (6)
-
repo owner -
repo owner - changed version to 1.7.8.6
-
repo owner Just submitted the fix for this. It'll be in the next build.
-
repo owner - changed status to resolved
Delivered in 1.7.8.6.
-
Account Deactivated Does the same thing for "export" and most likely other keywords.
-
repo owner Thanks for letting me know, Felipe. While Salesforce does publish a list of reserved words that can also be used as identifiers, as evidenced by this and other reported issues, it's quite incomplete. As a result I've tried to be conservative when it comes to adding reserved words/keywords as valid identifiers in Apex because of the potential for breaking the parser on valid code accidentally. For the most part I've been doing it reactively. I'll add
export
to the list and would certainly be interested to know if others are found that need to be added. - Log in to comment
Thanks for the report, Craig. This is one of the things about Apex that perplexes me...why language keywords/reserved words are allowed as identifiers. Anyway, sounds like
void
is intended to be a valid identifier name, though, so I'll add it to the list of keywords that can be used as identifiers in an upcoming release.