Menu

#817 Type mismatch not detected when passing an array of UDT incompatible with the expected UDT

closed
nobody
None
compiler
2023-09-17
2016-03-07
No

Case of compiler bug on checking if the type passed to a procedure matches with the expected:

  • When passing an array 'As UDT2' to a procedure with its parameter declared '() As UDT1', no compiler error (UDT2 being incompatible with UDT1).
  • No problem for a variable instead of an array.
  • No problem if one at least of the two types is a predefined type.

Example (the line 16 'test(u2(), u1(0))' should induce a compiler error):

Type UDT1
  Dim As Integer I1
End Type

Type UDT2
  Dim As Integer I2
End Type

Sub test (array() As UDT1, Byref u As UDT1)
End Sub

Dim As UDT1 u1(10)
Dim As UDT2 u2(10)

test(u1(), u1(0))  '' => OK
test(u2(), u1(0))  '' should be NOK
test(u1(), u2(0))  '' error 57: Type mismatch, at parameter 2   => OK
test(u2(), u2(0))  '' error 57: Type mismatch, at parameter 2   => OK

This is not a recent bug or a regression.
Already present since fbc version 0.12b!

Related

Bugs: #911

Discussion

  • Jeff Marshall

    Jeff Marshall - 2022-04-17

    Fixed / changed in fbc 1.10.0
    commit: [3eef323cdc9a866a0c9bbc130f88950d35363f00]

    fbc will now error on the mismatch which seems like should be the right thing to do.

     

    Related

    Commit: [3eef32]

  • Jeff Marshall

    Jeff Marshall - 2022-04-17
    • status: open --> closed
     
  • Jeff Marshall

    Jeff Marshall - 2023-09-17

    Related [#911]

     

    Related

    Bugs: #911


Log in to post a comment.

Auth0 Logo