Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/IDE/Code Templates    [ Add a report in this area ]  
Report #:  36085   Status: Reported
Error in 'for in' template
Project:  Delphi Build #:  10.0.2288.42451
Version:    10.0 Submitted By:   Ilshat Absharipov
Report Type:  Basic functionality failure Date Reported:  11/3/2006 1:41:33 AM
Severity:    Commonly encountered problem Last Updated: 1/4/2008 4:43:37 PM
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
4.00 out of 5
Total Votes: None
Description
We can use operator for...in with arrays. But when we use code template named 'forin' (for in loop) Delphi declare new variable of TObject type, that is not correct
Steps to Reproduce:
1. Declare array of any type
type MyArray: array of string;
2. Set cursor in some procedure of function body
3. Enter 'forin'
4. Press Ctrl+Space, code insight appears and we see that there is 'forin' template. Use it
5. Enter 'myvar' in 'MyElem' point and 'MyArray' in MyList point. Press Tab to end template
6. After that we have new variable myvar: TObject but MyArray is string array
Workarounds
None
Attachment
None
Comments

Sebastian Modersohn at 11/3/2006 4:45:52 AM -
For this to work along the lines of what you expect, the DeclareVariable call in the live template would need to figure out the base type of the enumerator, which is certainly possible, but definitely not implemented yet.

See http://delphi.wikia.com/wiki/Delphi_Live_Templates#forin for a new forint-Template which asks for the type of the iterator variable.

Additionally I'd recommend changing type and severity to C2, maybe C1. This is most definitely not a show stopper.

Server Response from: ETNACODE01