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] Problem subscribing to events when /undeclared+ is on #1620

Open
cpyrgas opened this issue Oct 30, 2024 · 1 comment
Open

[VFP] Problem subscribing to events when /undeclared+ is on #1620

cpyrgas opened this issue Oct 30, 2024 · 1 comment
Labels
Compiler FoxPro FoxPro dialect

Comments

@cpyrgas
Copy link

cpyrgas commented Oct 30, 2024

In the following code, when undeclared is on, the references to method myhandler() and the function myhandler_func() used for subscribing to the event are seen as undeclared memvars, resulting to runtime errors about them not being defined.

Not sure if this can be distinguished by the compiler.

#pragma options (memvar,on)
#pragma options (undeclared,on)

#pragma options (fox2,off)
//#pragma options (fox2,on) // does not make a difference

CLASS TestClass
	EVENT myEvent AS EventHandler
	CONSTRUCTOR()
		SELF:myEvent += EventHandler{ SELF , @myhandler() } // works OK
		SELF:myEvent += SELF:myhandler // works OK
		SELF:myEvent += myhandler // warning XS9073: Variable 'myhandler' has not been declared. Assuming this is a FIELD or a MEMVAR.

		SELF:myEvent += EventHandler{ NULL , @myhandler_func() } // warning XS9073: Variable 'myhandler_func' has not been declared. Assuming this is a FIELD or a MEMVAR.
		SELF:myEvent += myhandler_func // warning XS9073: Variable 'myhandler_func' has not been declared. Assuming this is a FIELD or a MEMVAR.

		SELF:myEvent(NULL,NULL)
	RETURN
	
	METHOD myhandler(sender AS OBJECT , e AS EventArgs) AS VOID
		? "invoked"
END CLASS

	FUNCTION myhandler_func(sender AS OBJECT , e AS EventArgs) AS VOID
		? "invoked"

FUNCTION Start( ) AS VOID
	TestClass{}
RETURN
@cpyrgas cpyrgas added Compiler FoxPro FoxPro dialect labels Oct 30, 2024
@RobertvanderHulst
Copy link
Member

This may be difficult to detect. I'll see what I can do.

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

No branches or pull requests

2 participants