Bug? Neither IDE nor compiler detects the invalid string declaration: Private strMsg as string=""Hello world"

toby

Well-Known Member
Licensed User
Longtime User
B4X:
Private strMsg as string=""Hello world"  'I meant to type "Hello world"
log(strMsg) 'Empty string is printed

As shown, there is an extra double quote, by mistake, at the beginning of the text. And both IDE and compiler ignore Hello World" part once they reach the second double quote thinking it's an empty string.
 
Last edited:

drgottjr

Expert
Licensed User
Longtime User
not ignored; doesn't compile here...
 

Attachments

  • capture.jpg
    capture.jpg
    35.7 KB · Views: 147
Last edited:

toby

Well-Known Member
Licensed User
Longtime User
test project attached
 

Attachments

  • extraQuote.zip
    264 KB · Views: 96

toby

Well-Known Member
Licensed User
Longtime User
I've finally figured out how to reproduce

Step 1. Declare a valid string.
B4X:
Private strMsg as string="Hello world"

Step 2. Insert a double quote anywhere in the above string:
B4X:
Private strMsg as string="Hell"o world"
IDE will happily accept it without further validation while compiler would truncate the string at the insertion point. The above declaration will cause strMsg to contain "Hell" instead of expected "Hello World".
 
Last edited:
Top