Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE    [ Add a report in this area ]  
Report #:  32473   Status: Reported
wrong variable declared while in with block
Project:  Delphi Build #:  10.0.2288.42451
Version:    10.0 Submitted By:   Uli Tessel
Report Type:  Basic functionality failure Date Reported:  8/8/2006 8:43:02 AM
Severity:    Commonly encountered problem Last Updated:
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (2 Total Ratings)
5.00 out of 5
Total Votes: 1
Description
While in a "with" block, local variables are added (by code templates like "for") with the wrong type.

Steps to Reproduce:
Create a VCL Form and create a method like the OnCreate:

procedure TForm1.FormCreate(Sender: TObject);
begin
end;

then add a "with Canvas do begin end" block, so you
get this:

procedure TForm1.FormCreate(Sender: TObject);
begin
  with Canvas do
  begin
    <cursor>
  end;
end;

now type "for" and <space>, so the code template for "for" opens.
Keep the "i" and the "0", so press <tab> two times. Change the
"list.count - 1" to 10 and press <tab>

the variable "i" is added to the method, but with the wrong type:
it should be integer instead fo TCanvas:

procedure TForm1.FormCreate(Sender: TObject);
var
  I: TCanvas;
begin
  with canvas do
  begin
    for I := 0 to 10 - 1 do


  end;
end;
Workarounds
None
Attachment
None
Comments

Leo Siefert at 8/9/2006 6:07:59 AM -
Confirmed.  Also the cursor does not end up indented properly.

Server Response from: ETNACODE01