Results 1 to 10 of 10

Thread: DFRefactor 20190426: Unused local variables curiosity

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Posts
    740

    Default DFRefactor 20190426: Unused local variables curiosity

    Hello,

    Just a curiosity, I don't understand it as a bug.

    Let's assume following code:
    Code:
    Procedure MyProcedure
        String sVarN1, sVarN2
        
        Move "something" to sVarN1
        Move "test" to sVarN2
    End_Procedure
    This piece of code is valid for the compiler. If I make use of unused local variables sVarN1 gets deleted and program doesn't compile.

    I see it as a programmer error.

    Regards.
    I know, I have to learn a lot of things (english the first thing...)

  2. #2
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    9,178

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    I recently ran into this. It's not DFRefactor, but 19.1. Earlier versions ignored the comma, 19.1 considers it a part of the variable name: sVarN1, instead of sVarN1

    Well - DFRefactor will remove it - but AFAIK, 19.1 will not compile it.
    Garret

    If a little knowledge is a dangerous thing, an encyclopedia set is nothing short of terrorism...



  3. #3

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    Hi,

    I logged this: https://projects.vdf-guidance.com/issues/159

    But we might not patch it as it isn't valid code IMO, even while it compiles.
    Then again, it is never nice when things break after a refactor. It is up to the compiler to decide and point out the programmer error.

    What happens is that the variable is parsed as variable name "sVarN1," in the declaration line and as "sVarN1" in the code.
    So as far as DfRefactor cares, they are different variables.
    It is logged so we can consider what should be done. But obviously it is not high priority atm.
    --
    Wil

  4. #4
    Join Date
    Feb 2009
    Location
    Goteborg, Sweden
    Posts
    2,864

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    I sincerely hope that DAW is looking into this.

    As it seems to be something that was introduced by the 19.1 compiler, it should be corrected.
    Nils Svedmyr
    RDC Tools International
    www.rdctools.com

    "Humor is reason gone mad"
    Groucho Marx

  5. #5
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    8,667

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    Nils,

    The comma does not belong in the variable declaration line.

    It is not a new thing introduced in 19.1. Look at the screenshots (v16, v18.2 and v19.1) they show the same about how they treat the comma.

    If you want to do something about it make DFRefactor trap the comma and remove it.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	16.0.png 
Views:	89 
Size:	6.8 KB 
ID:	12940   Click image for larger version. 

Name:	18.2.png 
Views:	28 
Size:	11.6 KB 
ID:	12941   Click image for larger version. 

Name:	19.1.png 
Views:	26 
Size:	9.3 KB 
ID:	12942  
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  6. #6
    Join Date
    Feb 2009
    Location
    Goteborg, Sweden
    Posts
    2,864

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    Vincent,

    Of course the comma does not belong at the variable line. Who has said otherwise?

    I referred to Garrets comment about the change to earlier DataFlex versions.
    Nils Svedmyr
    RDC Tools International
    www.rdctools.com

    "Humor is reason gone mad"
    Groucho Marx

  7. #7
    Join Date
    Mar 2009
    Location
    Beech Hill - a village near Reading in the UK
    Posts
    1,147

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    Vincent

    The point is, how did it get to the stage where it shows as an "Internal error: syntax error" in the debugger? This should fail to compile and should never get to the debugger! In essence, the runtime (or maybe just the debugger) is picking up an error the compiler should have caught. It says it right there: "syntax error" - that's what compilers are there to catch!

    Mike

  8. #8
    Join Date
    Feb 2009
    Location
    Goteborg, Sweden
    Posts
    2,864

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    Couldn't agree more!
    Nils Svedmyr
    RDC Tools International
    www.rdctools.com

    "Humor is reason gone mad"
    Groucho Marx

  9. #9
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    8,667

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    Mike,

    I think it is the debugger but I agree that the compiler should not accept the comma either. Will log this issue.
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  10. #10
    Join Date
    Feb 2009
    Location
    South Florida
    Posts
    3,528

    Default Re: DFRefactor 20190426: Unused local variables curiosity

    well the compiler obviously ignores it as whitespace and the debugger doesnt and thinks its a variable name
    Michael Salzlechner
    StarZen Technologies, Inc
    http.://www.starzen.com

    Development Blog
    http://www.salzlechner.com/dev

    DataFlex Package Manager (aka Nuget for DataFlex)
    http://windowsdeveloper.com/dfPackage

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •