Log On
Embarcadero Home
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
Quality Central
Delphi-BCB
Compiler
Delphi
Anonymous Methods
BASM
Code Generation/Optimization
Error Recovery
Errors - Warnings
Exceptions
Execution
Finalization
Generics
Header Generation
Interaction with UI
Interfaces
Language
Linker
Make Logic
Memory Manager
OBJ Generation
OBJ Support
Other Compiler
Packages
RTTI
String Resources
TD Debug Info
Thread Local Storage
Version resilience
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/Compiler/Delphi/Errors - Warnings
[ Add a report in this area ]
Report #:
8770
Status:
Open
Warning for duplicate identifiers in with-scope
Project:
Delphi
Build #:
7.0.4.453
Version:
7.0
Submitted By:
Hallvard Vassbotn
Report Type:
Suggestion / Enhancement Request
Date Reported:
8/10/2004 6:01:35 AM
Severity:
Commonly encountered problem
Last Updated:
1/9/2007 10:42:57 AM
Platform:
95, 98, 2000, NT, XP
Internal Tracking #:
Resolution:
Duplicate
Resolved in Build:
:
None
Duplicate of:
2667
Voting and Rating
Overall Rating:
(4 Total Ratings)
4.75 out of 5
Total Votes:
3
Description
There should be a new Warning for potential name conflicts when the same identifier is defined in a with-scope and a non-with scope.
Again (as in QC #8761), the goal is to catch unintended changes in semantics after changes have been made to used units - but this time specifically for cases where the with-statment changes the scoping rules and introduces potential name conflicts.
IMO, if we could have this kind of warning for with statements, it would be the first steps towards patching one of the very few sorespots of the language.
Steps to Reproduce:
With-statements are tricker to design good warnings for. I think the rule-of-thumb should be that it doesn't warn on local identfiers defined in the same unit. Trust the programmer have control over the identifiers and name space-pollution caused by himself in the current unit. Local changes that have local effect isn't that harmful.
Once there is a name-clash between a local identifier and an identifier in the with-scope, generate a warning. This will catch future changes in external units that cause semantic changes.
For instance:
Unit Foo;
type
TGadget = class
bar: integer;
end
...
Unit Bar;
var
a : TGadget;
foo: integer
begin
with a do
foo := 123;
end;
This is version 1. Code compiles without warnings and works correctly. Now Mr. Component on the other side of the globe makes an update to the TGadget class:
Unit Foo;
type
TGadget = class
foo: integer; // New feature!
bar: integer;
end
Now Joe Doe recompiles his code with this new version:
Unit Bar;
var
a : TGadget;
foo: integer
begin
with a do
foo := 123;
end;
With D7, there is no warning. Code compiles, but fails at run-time. In a future version of the compiler he would get warning such as:
Warning: Potential name conflict: foo declared in unit Bar and Foo.TGadget.
In this case, to get rid of the warning, the programmer could change the code to
Bar.foo := 123;
or he could get rid of the with-statement.
Workarounds
None
Attachment
None
Comments
Kristofer Skaug at 8/25/2004 4:51:11 AM
-
Also related to #1615, although perhaps not 100% duplicate.
View Your Reports
Search
Server Response from: CODE1
Developer Tools
Blackfish SQL
C++Builder
Delphi
Delphi for PHP
Delphi Prism
InterBase
JBuilder
J Optimizer
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Chats
Discussion Forums
Examples (CodeCentral)
Member Services
About