freebasic / fbc

FreeBASIC is a completely free, open-source, multi-platform BASIC compiler, with syntax similar to MS-QuickBASIC, that adds new features such as pointers, object orientation, unsigned data types, inline assembly, and many others.
https://www.freebasic.net
905 stars 139 forks source link

Invalid assignment/conversion, before 'Then' in function returned Const ZString Ptr #424

Closed zamabuvaraeu closed 7 months ago

zamabuvaraeu commented 7 months ago

I declared a function that takes and returns a constant:

Declare Function TestConstZStringPtr( _
    ByVal key As Const ZString Ptr _
) As Const ZString Ptr

If you put the function inside the condition and pass Str(number), the code works:

If TestConstZStringPtr(Str(265)) Then
End If

If you pass Str(variable) and assign the function result to the variable, then the code works:

Dim Number As Integer = 0
Dim result As Const ZString Ptr = TestConstZStringPtr(Str(Number))

If you pass Str(variable) and put the function inside the condition, the code does not work:

' error 181: Invalid assignment/conversion, before 'Then' in 'If TestConstZStringPtr(Str(Number)) Then'
If TestConstZStringPtr(Str(Number)) Then
End If
jayrm commented 7 months ago

Thank-you for the report

fixed in fbc-1.20.0 see commit [d0201869deeb33d7c4aa980953a4daf6cee411f4]