Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing error with var-len arrays in UDT #355

Open
mudhairless opened this issue Feb 6, 2022 · 1 comment
Open

Parsing error with var-len arrays in UDT #355

mudhairless opened this issue Feb 6, 2022 · 1 comment

Comments

@mudhairless
Copy link
Contributor

Issue is present in both 32 and 64 bit compilers with versions 1.09.0, 1.08.1, and 1.07.3 known affected.

Error message from compiler:
fbc-issue.bas(10) error 3: Expected End-of-Line, found '.' in 'redim test(0,0).array(0)'

I have only tested this on Windows but it should not differ between platforms.

type aType
    array(any) as integer
end type
 
dim test(any,any) as aType

redim test(0,0)

'doesnt work
redim test(0,0).array(0)

'works
redim (test(0,0).array)(0)
@dkl
Copy link
Member

dkl commented Oct 3, 2022

Some related information: This sounds to me like it's the classic redim parsing issue. Since it can be used to declare variables, there needed to be some differentiation between redim id(... and redim expression.... So I think redim test(0,0) looks like a variable declaration and the parser simply doesn't look-ahead far enough to see the .array(0) following behind it which could be used to indicate that it's actually an expression.

On the one hand, it doesn't have infinite look-ahead (if I remember correctly), on the other hand it can't really parse an expression it it's an array declaration, because the symbol isn't defined yet, (lower to upper) isn't valid in expressions, etc. It would be quite a challenge to try and work-around that. I remember using the extra parentheses as in redim (expression) to avoid the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants