Welcome, Guest
Username: Password: Remember me
Please use this forum for suggestions to the XSharp Development Team
  • Page:
  • 1

TOPIC:

Report/warning to find potential problems switching to case-sensitive mode 24 May 2022 11:39 #22598

  • Otto
  • Otto's Avatar
  • Topic Author


  • Posts: 170
  • 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.

    Please Log in or Create an account to join the conversation.

    Report/warning to find potential problems switching to case-sensitive mode 24 May 2022 14:53 #22600

    • VR


  • Posts: 68
  • One way to "fix" this issue would be to enable the EnforceSelf compile option.

    Please Log in or Create an account to join the conversation.

    Report/warning to find potential problems switching to case-sensitive mode 24 May 2022 14:54 #22601

    • Otto
    • Otto's Avatar
    • Topic Author


  • Posts: 170
  • That is a good suggestion.

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1