Report/warning to find potential problems switching to case-sensitive mode

Have some feedback and input to share?
Don't be shy and drop us a note. We want to hear from you and strive to make our site better and more user friendly for our guests and members a like.
Post Reply
User avatar
Otto
Posts: 174
Joined: Wed Sep 30, 2015 6:22 pm

Report/warning to find potential problems switching to case-sensitive mode

Post by Otto »

We have an example where a local variable is called the same as a getter (access) on a class, but only differs in the case of the first letter.

Example:
USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text


FUNCTION Start() AS VOID STRICT
? "Hello World! Today is ",Today()
var myFoo := Foo{}
? myFoo:MyMethod(131)
WAIT
RETURN


CLASS Foo
ACCESS Bar AS INT
RETURN 15

METHOD MyMethod(bar AS INT) AS INT
bar := bar * 2
RETURN Bar

END CLASS

In the case sensitive situation MyMethod returns 15, every time.
In the case insensitive situation MyMethod returns 2x the input of the method, in this case 262.

I'm not aware of a warning in the case-insensitive mode that warns for this.
It would be nice to be able to get a warning for this. Or maybe a report one can run upfront to identify this kind of potential problems.
VR
Posts: 98
Joined: Sun Aug 23, 2020 3:07 pm
Location: Italy

Report/warning to find potential problems switching to case-sensitive mode

Post by VR »

One way to "fix" this issue would be to enable the EnforceSelf compile option.
User avatar
Otto
Posts: 174
Joined: Wed Sep 30, 2015 6:22 pm

Report/warning to find potential problems switching to case-sensitive mode

Post by Otto »

That is a good suggestion.
Post Reply