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

[VFP] Bogus compiler warning about not used variable, when /fox2 is enabled #1627

Open
cpyrgas opened this issue Nov 11, 2024 · 4 comments
Open
Labels

Comments

@cpyrgas
Copy link

cpyrgas commented Nov 11, 2024

Following results to error XS0165: Use of possibly unassigned local variable 'u'

#pragma options(initlocals,off)
#pragma options(fox2,on) // happens with fox2+ enabled only
FUNCTION Start( ) AS VOID 
LOCAL u
u := 1  // error XS0165

Also same warning is reported in this case, but it is correct in this case I assume?

#pragma options(initlocals,off)
#pragma options(fox2,off) // doesn't matter for this one
PROCEDURE Test1()
LOCAL u
DIMENSION u[100] // error XS0165
RETURN

@cpyrgas cpyrgas added bug Compiler FoxPro FoxPro dialect labels Nov 11, 2024
@cpyrgas cpyrgas changed the title [VF} Bogus compiler warning about not used variable, when /fox2 is enabled [VFP] Bogus compiler warning about not used variable, when /fox2 is enabled Nov 11, 2024
@RobertvanderHulst
Copy link
Member

The reason for XS10165 in this code with /fox2 is that when u is an array, then the assignment u := 1 will fill the whole array with the value 1.
For that reason the assignment is translated into: u := XSharp.VFP.Functions.__FoxAssign(u, 1)
The __FoxAssign function needs to know the original type of u to decide what to do.

@RobertvanderHulst
Copy link
Member

RobertvanderHulst commented Nov 11, 2024

In the second example the compiler outputs this:
u := XSharp.VFP.Functions.__FoxRedim(u, 100u, 0u)
The FoxPro dimension command can be used to redimension an existing array.

@cpyrgas
Copy link
Author

cpyrgas commented Nov 11, 2024

OK, I understand. Maybe in the future we can implement a compiler option (re-introduce fox1?) that enables/disables some of such VFP features, so people can still use the VFP dialect, but let the compiler create more robust code (and make more compile-time checks).

@RobertvanderHulst
Copy link
Member

Chris
The __FoxAssign() code only gets generated with /fox2 enabled IIRC.

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

No branches or pull requests

2 participants