antlr/antlr4 · warning · NotSupportedException
EdgeMap of type {0} is supported yet.
Error message
EdgeMap of type {0} is supported yet. What it means
AbstractEdgeMap.PutAll switches on the concrete type of the source map; ArrayEdgeMap handles EmptyEdgeMap and fellow ArrayEdgeMap instances, and any other AbstractEdgeMap subclass falls into the default branch and throws NotSupportedException. The message ('EdgeMap of type {0} is supported yet.') is even missing an 'not' — the intent is 'is not supported yet'. Edge maps are internal DFA adjacency structures; user code normally never touches them.
Source
Thrown at runtime/CSharp/src/Dfa/ArrayEdgeMap.cs:132
{
if (m is SparseEdgeMap<T>)
{
SparseEdgeMap<T> other = (SparseEdgeMap<T>)m;
lock (other)
{
int[] keys = other.Keys;
IList<T> values = other.Values;
Antlr4.Runtime.Dfa.ArrayEdgeMap<T> result = this;
for (int i = 0; i < values.Count; i++)
{
result = ((Antlr4.Runtime.Dfa.ArrayEdgeMap<T>)result.Put(keys[i], values[i]));
}
return result;
}
}
else
{
throw new NotSupportedException(string.Format("EdgeMap of type {0} is supported yet.", m.GetType().FullName));
}
}
}
}
public override AbstractEdgeMap<T> Clear()
{
return new EmptyEdgeMap<T>(minIndex, maxIndex);
}
public override IReadOnlyDictionary<int, T> ToMap()
{
if (IsEmpty)
{
return Sharpen.Collections.EmptyMap<int, T>();
}
IDictionary<int, T> result = new SortedDictionary<int, T>();View on GitHub (pinned to 7d5770395b)
Solutions
- Do not mix edge map implementations in PutAll; iterate the other map's entries and call Put(key, value) instead
- If you need full PutAll support, implement the merge loop yourself over ToMap()/entries of the source map
- Treat the Antlr4.Runtime.Dfa edge-map classes as internal — build your own dictionary-based adjacency structure for custom work
Example fix
// before
ArrayEdgeMap<DFAState> merged = (ArrayEdgeMap<DFAState>)map.PutAll(otherMap); // throws for SingularEdgeMap
// after
AbstractEdgeMap<DFAState> merged = map;
foreach (var kv in otherMap.ToMap())
merged = merged.Put(kv.Key, kv.Value); Defensive patterns
Strategy: fallback
Type guard
static bool IsSupportedMergeSource(AbstractEdgeMap<DFAState> m) => m is EmptyEdgeMap<DFAState> || m is ArrayEdgeMap<DFAState>;
Prevention
- Merge edge maps by iterating entries and calling Put instead of PutAll when types differ
- Treat the Antlr4.Runtime.Dfa edge-map hierarchy as internal API; don't build on it
When it happens
Trigger: Calling PutAll on an ArrayEdgeMap with a source map that is neither EmptyEdgeMap nor ArrayEdgeMap (in practice a SingularEdgeMap from the same internal hierarchy). This requires directly using the internal Antlr4.Runtime.Dfa edge-map API, e.g. in custom DFA cache implementations or ATN experiments.
Common situations: Custom DFA/edge-map experiments; code copied from a different ANTLR runtime port where PutAll supports more map types; none in normal generated-parser usage.
Related errors
- This ATN simulator does not support clearing the DFA.
- Only precedence DFAs may contain a precedence start state.
- This set is readonly
- This ATN simulator does not support clearing the DFA.
- Only precedence DFAs may contain a precedence start state.
AI-assisted analysis of antlr/antlr4@7d5770395b (2026-08-14).
Data as JSON: /api/errors/8d8e43625b5d4164.
Report an issue: GitHub.