With/End With usage problem with Asciiz/String members
issueid=321 18-10-2011 12:09
Super Moderator
Number of reported issues by Petr Schreiber: 131
With/End With usage problem with Asciiz/String members
There is false positive error generated when string members are manipulated inside With/End With

While numeric members of UDT are handled correctly in With/End With, STRING/ASCIIZ based ones seem to have problem.
The issue seems to be related to recently introduced checking for double concatenation.

The reason seems to be fact, that ThinBASIC supports the following symbols for string concatenation:
  • +
  • &
  • . (like in PHP)

Dim s1, s2, s3 As String

s1 = "Hi" + ", how is it going?"       ' -- Valid syntax
s2 = "Hi" & ", how is it going?"       ' -- Valid syntax
s3 = "Hi" . ", how is it going?"       ' -- Valid syntax
And here is code demonstrating the issue:
Type Record
  sName         As String
  sSurName      As String
  sCompleteName As String
End Type

Dim human As Record

' -- This is OK
human.sName         = "John"
human.sSurName      = "Carmack" 
human.sCompleteName = human.sName + human.sSurName

' -- This does not work
With human
  .sName         = "John"
  .sSurName      = "Carmack" 
  .sCompleteName = .sName + .sSurName
End With
The problem is the parser found + and ., and it false positively expects these to be two concatenation operators. That would be true in other case, but not inside With/End With.

I think the usage of dot as concatenation operator might cause even more trouble, because it was introduced before UDTs were supported in ThinBASIC and it clashes with the dotted syntax a bit.


Petr
Issue Details
Issue Number 321
Project thinBasic
Category Core engine (thinCore.dll)
Status Fixed
Priority 5 - Medium
Affected Version 1.8.9
Fixed Version 1.9.1
Milestone thinBasic 1.9.0.0
Users able to reproduce bug 0
Users unable to reproduce bug 0
Assigned Users (none)
Tags (none)




23-10-2011 17:53
thinBasic author
I think I've fixed this.
Update in next release.

+ Reply