I have some old code that used to work (tested with 2014r2.1 and it still worked back then)
Starting with 2014r3 this same code no longer seems to work.
I don’t know if it is expected behavior or not.
this is example code of the problem
Private Function CheckValue(CheckType As Integer, number1 As Double, number2 As Double) As Boolean
Select Case CheckType
Case ValComparison.Less
if number1<number2 then Return true
End Select
End Function
I’m using an enumarator which is of the type integer
Public Enum ValComparison
Less = VAL_LESS
LessOrEqual = VAL_LESS_EQUAL
Equal = VAL_EQUAL
GreaterOrEqual = VAL_GREATER_EQUAL
Greater = VAL_GREATER
the values here are based on constants
for instance
Const VAL_LESS = 4
The code is called this way
Dim bTestResult As Boolean
bTestResult=CheckValue(ValComparison.Less,1, 2)
on 2014r2.1 all is fine and the code runs as expected.
starting with 2014r3 I get an error
Parameter “CheckType” expects type int32, but this is enum … valcomparison.
changing the code to
Private Function CheckValue(CheckType As Integer, number1 As Double, number2 As Double) As Boolean
Select Case CheckType
case VAL_LESS
if number1<number2 then Return true
End Select
End Function
and calling it this way
Dim bTestResult As Boolean
bTestResult=CheckValue(VAL_LESS,1, 2)
works
Changing the code to
Private Function CheckValue(CheckType As ValComparison, number1 As Double, number2 As Double) As Boolean
Select Case CheckType
case ValComparison.Less
if number1<number2 then Return true
End Select
End Function
and calling it this way
Dim bTestResult As Boolean
bTestResult=CheckValue(ValComparison.Less,1, 2)
also works
Since the enumerator is defined as integer, shouldn’t this still work?
ValComparison is indeed an enumarator, but its values are defined as integer (in the case of VAL_LESS, it’s 4)
The parameter “CheckType” for the function CheckValue is an integer
Strangely enough calling it with the constant VAL_LESS does work, although that one is not defined as integer, but as a number.
Also calling it by changing the parameter to be a ValComparison and passing it a ValComparison value (ie ValComparison.Less, therefore an integer) does work.
I think this might be related to <https://xojo.com/issue/35645>.
Is my reasoning wrong, or is this a bug?