Code incorrectly highlighted as errors

Issue #376 resolved
Steve Jones created an issue

Hi Scott, I have two instance in a class where code is being highlighted as errors, and I don't believe they should be. One is the use of the word 'Format' in a SOQL query on the Report object, the other is declaring a variable as Transient in a method. Both of these are running fine in our live org and are not picked up as problems in the Salesforce IDE.

The highlighted errors beneath Transient disappear if each transient line is removed.

Comments (9)

  1. Scott Wells repo owner

    Steve, thanks for the report. These are almost certainly minor parser issues. I'll take a look shortly.

  2. Scott Wells repo owner

    Steve, regarding the first error shown where the transient modifier keyword is highlighted, that looks correct to me. Correct me if I'm wrong, but local variables shouldn't be declared transient, only member variables to omit them from Visualforce view state/JSON/XML serialization:

    https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_transient.htm

    Again, it's possible there's a use of this modifier in Apex that I'm not familiar with, but I'm surprised that would even compile. Please let me know if that's actually controlling something.

    I'll take a look at the other two and see what's going on. The Format one is just another instance of allowing a reserved keyword to be used as an identifier. I'm not 100% sure what's going on at the bottom of that method with so many things being marked as invalid, though. I'll see what I can find.

  3. Scott Wells repo owner

    Steve, can you see if removing the transient keyword from local variables in that code removes all of the subsequent errors. I'm not able to reproduce exactly what you're seeing, but basically it seems like that keyword is preventing the parser from recovering properly. I'll work on that, and of course if transient should be supported as a local variable modifier, I'll go that route, but I'd like to understand what role it's playing in the subsequent errors in that method body before trying to reproduce something that's potentially a side-effect.

  4. Scott Wells repo owner

    Okay, I decided to add an allowance for transient on local variables. You won't get a parse error, but I'm pretty sure it doesn't do anything either. When I add local code inspections, I may include one that flags that as a warning.

    I've also fixed the Format issue. These will all be included in the next build.

  5. Scott Wells repo owner

    Delivered with 1.7.3.8. Please let me know if the fix for transient doesn't also fix the other errors in that same method.

  6. Steve Jones reporter

    Hi Scott,

    That's all looking fine now. All of the errors below the transient variables are gone, and format is showing correctly.

    You're absolutely right about my over zealous application of transient as well!

  7. Log in to comment