Skip to content

Commit 7d3ce1b

Browse files
author
Steve Ives
committed
Trap ArgumentException when a user-defined token has the same name as a builtin token.
1 parent 2b7c2bb commit 7d3ce1b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

CodeGenEngine/Tokenizer.dbl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,7 +1866,16 @@ namespace CodeGen.Engine
18661866
newMeta.Name = ut.Name
18671867
newMeta.TypeOfToken = TokenType.User
18681868
newMeta.Validity = TokenValidity.Anywhere
1869-
addLookupToken(newMeta)
1869+
try
1870+
begin
1871+
addLookupToken(newMeta)
1872+
end
1873+
catch (e, @ArgumentException)
1874+
begin
1875+
;;User token name clashes with a "baked in" token.
1876+
reportError(String.Format("{0} may not be used as a user-defined token. A token with that name already exists!", ut.Name))
1877+
end
1878+
endtry
18701879
end
18711880
end
18721881
endmethod

0 commit comments

Comments
 (0)