Menu

#1009 Invalid symbol when accessing indexed PROPERTY arrays BYREF

open
nobody
None
compiler
2024-11-17
2024-11-17
No

When accessing an indexed property array the parser seems stop incorrectly before reading the entire expression. The exact syntax error messages vary depending on the usage.

The following code demonstrates one such instance:

type A
    b as long
end type

type C
    __ as integer
    declare property p( byval index as long ) byref as A
end type

type D
    __ as integer
    declare property p( byval index as long ) byref as A
    declare property p( byval index as long, byref value as A )
end type

type E
    __ as integer
    declare property q( byval index as long ) byref as D
    declare property q( byval index as long, byref value as D )
end type

dim x as C
dim y as D
dim z as E

print x.p(0).b
print y.p(0).b
print z.q(0).p(0).b

x.p(0).b = 1
y.p(0).b = 1
z.q(0).p(0).b = 1

'' property.bas(31) error 8: Undefined symbol, b in 'y.p(0).b = 1'
'' property.bas(32) error 8: Undefined symbol, p in 'z.q(0).p(0).b = 1'

In exploration of fixing this parser-proccall.bas:cProcCall() which is used for resolving the call to property getters/setters, assumes that if an equal sign = is not immediately seen then the expression must be a getter with a result to be discarded. What should probably happen here is to check for member access immediately following (. | ->) and then continue parsing for the next member before to complete the expression.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB