Skip to content

Commit 5f875e0

Browse files
committed
Add a check to ensure language builders don't have duplicate definitions
1 parent 82e15fc commit 5f875e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Src/FastData.Generator/Framework/TypeMap.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ public TypeMap(IList<ITypeDef> typeSpecs)
1111
for (int i = 0; i < typeSpecs.Count; i++)
1212
{
1313
ITypeDef spec = typeSpecs[i];
14-
_index[(byte)spec.DataType] = spec;
14+
byte idx = (byte)spec.DataType;
15+
16+
//Quick check to see if a language have a duplicate definition for a DataType
17+
if (_index[idx] != null)
18+
throw new InvalidOperationException($"Duplicate type spec found for '{spec.DataType}'");
19+
20+
_index[idx] = spec;
1521
}
1622
}
1723

0 commit comments

Comments
 (0)