SpiderBasic 3.20 does not enforce AddElement() for structured list assignment, unlike PureBasic

Found an issue in SpiderBasic ? Please report it here !
Webarion
Posts: 14
Joined: Mon Mar 04, 2024 10:47 pm

SpiderBasic 3.20 does not enforce AddElement() for structured list assignment, unlike PureBasic

Post by Webarion »

Hello, I found a discrepancy between the PureBasic and SpiderBasic compilers regarding structured dynamic lists. In PureBasic, the following code throws a compiler error because the list element must be explicitly initialized with AddElement() before assignment. However, SpiderBasic compiles it successfully without any warnings, which breaks the "write once, compile anywhere" syntax rule between PB and SB. Reproduce

Code: Select all

Structure MyMap
  List MyList.i()
EndStructure

Define NewMap MyMap.MyMap()

; This line compiles fine in SB, but causes a compiler error in PB:
MyMap("1")\MyList() = 1
Expected behavior: SpiderBasic should throw a compiler error stating that AddElement() is required, or that direct assignment to a structured list is not allowed, matching PureBasic's strict type safety. Best regards.