Jump to content
Sign in to follow this  
Sonjli

Evaluate class field inside anonymous method

Recommended Posts

Hello,

I hope to be in the right place.

Also, I don't find this behaviour in forum neither in embt quality.

 

I am in debug with a breakpoint inside an anon method and when I try to evaluate a variable (CTRL + F7, mouse over, watches, etc. ) I get a "undeclared identifier" if I use a class field.

 

Example:

 

TmyDM = class(TDataModule)
	Comp: TADOQuery;
    ...
end;

...

procedure ...blabla...;
var
	CompForDebug: TADOQuery;
begin
    Comp.Close;
    Comp.Parameters.ParamByName('test').Value := 100;
    Comp.Open; // <-- Here evaluate "Comp". I get the right thing
	FmyList.ForEach(
    	procedure(const obj: IMyThing)
        var
        	CompForDebugLocal: TADOQuery;
        begin
        	Comp.Close;
            Comp.Parameters.ParamByName('test').Value := 100;
            Comp.Open; // <-- Here evaluate "Comp". I get "Undeclared identifier"
            
            // This doesn't work:
            CompForDebugLocal := Comp; 
        	CompForDebugLocal.Close;
            CompForDebugLocal.Parameters.ParamByName('test').Value := 100;
            CompForDebugLocal.Open; // <-- Here evaluate "Comp". I get "Undeclared identifier"
            
            // This doesn't work:
            CompForDebug := Comp; 
        	CompForDebug.Close;
            CompForDebug.Parameters.ParamByName('test').Value := 100;
            CompForDebug.Open; // <-- Here evaluate "Comp". I get the right thing
            
        end
    );
end;

 

Share this post


Link to post

Comp is captured and I can confirm debugger evaluator is not working.

Declare LComp: TADOQuery in anonymous method and assign LComp := Comp. Then it will work to evaluate LComp....

Share this post


Link to post
9 minutes ago, Cristian Peța said:

Comp is captured and I can confirm debugger evaluator is not working.

Declare LComp: TADOQuery in anonymous method and assign LComp := Comp. Then it will work to evaluate LComp....

Ok, thanks. I needed a confirmation.

Same exact behaviour is for inline variables inside anon method... no way to evaluate them during debug.

It's frustrating if you are working with Spring4d or other modern libraries.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×