tdf#123263 Type checking SbiSymDef and Array

himajin100000 himajin100000 at
Sun Feb 10 21:28:55 UTC 2019

Just for Information
I'm now tackling on


and I'm now stuck.

I want to sort out my idea, share my headaches :-) , and solicit advice.
1. In StarBasic, assignment is done in SbiRuntime::StepPUT, but 
StarBasic only type-checks with checkUnoStructCopy.(see the URL below)

2. Some functions like Split( defined in SbRtl_Split in C++), requires 
data that can be converted to string type. A call of GetString ,which 
internally calls SbxValue::Get(SbxValues rRes), does this.

3. Even when type of left variable and right expression in assignment 
are not of the same type, sometimes it's preferable to implicitly 
convert to the type of lvalue, and I believe SbxValue::Get(SbxValues 
rRes) would be help.

4. With these in mind, I wrote

refVar is for the left variable and refVal is for right value.
IsFixed() is for Variable type.

5. This did not solve the issue. I printf-ed with SAL_INFO the types of 
refVar and refVal (SbxDataType) static_cast-ed to int, while running the 
code in the bug report. Result indicated SbxSTRING and SbxINTEGER with 
no SbxARRAY information.

6. I decided on finding where these type data is taken from.
And, I found out that on parsing, identifiers are managed with 
SbiSymDef, and parenthesis for arrays are handled separatly in 

Variable declarations of array type in StarBasic is as follows:

Dim x() As Integer

'As Integer' part is handled in SbiParser::TypeDecl, which calls 
SbiSymDef::SetType, but parethesis is handled before that in VarDecl. To 
carry over this information, I added the third optional parameter to 

7. And by doing these, the code in the bug report seemed to work, and I 
submitted the patch to gerrit.Unfortunately that resulted in unit test 

Unit test error: Symbol oControlGroup already defined differently.

I searched OpenGrok for the identifier oControlGroup and hit this.

9. I tried this code on my own local machine with SAL_INFOs, and
understood StarBasic wants the left expression of dot character to be of 

before my patch, objects can be stored only to variables of type 
SbxOBJECT or SbxVARIABLE. Sometimes StarBasic tries to 
SbiSymDef::SetTypes( SbxOBJECT ) thingy, often with interim variables, 
if the variable is defined as SbxVARIANT. The type of SbiSymDef is used 
for if statements later.

As suggested by the algorythm above type of SbiSymDef is essential, and 
I don't want change this.

Also, expressions like the following
Dim x() As Object


x is an of (SbxOBJECT | SbxARRAY)  and x(i) is SbxOBJECT but I'm not 
sure whether I should/can hold x(i) as SbiSymDef

More information about the LibreOffice mailing list