Closed StephanWald closed 2 months ago
The problem here is that we only consider first initialization of a variable when computing the variable type. As the first initialization was null
no members are available later on.
Following an example without null()
but works the same as original example.
tc!=new java.util.List()
tc! = BBjAPI()
tc!.add("item"); REM can not access .getThinClient() but List members
It is not easy to derive a proper variable type as shown in the example below:
x = 2
tc!=new java.util.List()
if(x = 3)
tc! = BBjAPI()
endif
tc!.getThinClient()
What we can try to do, is looking up the siblings for the first initialization and try compute the type. This will work in some cases, but not in general, so the best way is still using declare
:
declare BBjAPI tc!
tc!=null()
tc! = BBjAPI()
tc!.getThinClient()
Note: this will also make scoping->linking->build slower.
declare needs to be used in that case
In the following example
the getClientFileSystem() gets flagged. If you remove the first line assigning tc!=null() then all works as expected. Probably an initialization with null() should simply be ignored for the type discovery?