Compiler exceptions
This commit is contained in:
@@ -267,6 +267,10 @@ begin
|
||||
if not IsValidIdentifier(identifier.Name) then
|
||||
raise EBinderException.CreateFmt('Invalid identifier name: "%s".', [identifier.Name]);
|
||||
|
||||
// Check if the identifier is already defined in the current scope builder to avoid Scope Asserts.
|
||||
if FCurrentBuilder.FindSlot(identifier.Name) >= 0 then
|
||||
raise EBinderException.CreateFmt('Variable "%s" is already defined in this scope.', [identifier.Name]);
|
||||
|
||||
slot := FCurrentBuilder.Define(identifier.Name);
|
||||
addr := TResolvedAddress.Create(akLocalOrParent, 0, slot);
|
||||
|
||||
@@ -334,6 +338,10 @@ begin
|
||||
SetLength(newParams, Length(Node.Parameters));
|
||||
for i := 0 to High(Node.Parameters) do
|
||||
begin
|
||||
// Parameter names must also be checked for uniqueness, though usually guaranteed by Parser/AST construction
|
||||
if FCurrentBuilder.FindSlot(Node.Parameters[i].Name) >= 0 then
|
||||
raise EBinderException.CreateFmt('Duplicate parameter name "%s".', [Node.Parameters[i].Name]);
|
||||
|
||||
slot := FCurrentBuilder.Define(Node.Parameters[i].Name);
|
||||
addr := TResolvedAddress.Create(akLocalOrParent, 0, slot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user