diff --git a/Sources/SynKit/Libraries/Parser/ParseError.cs b/Sources/SynKit/Libraries/Parser/ParseError.cs index 9756a1b2..78f6e0c0 100644 --- a/Sources/SynKit/Libraries/Parser/ParseError.cs +++ b/Sources/SynKit/Libraries/Parser/ParseError.cs @@ -65,16 +65,16 @@ private ParseError(IReadOnlyDictionary elements, obje if (cmp < 0) return second; if (cmp > 0) return first; // Both of them got stuck at the same place, merge entries - var elements = first.Elements.Values.ToDictionary(e => e.Context, e => e.Expected.ToHashSet()); + var elements = first.Elements.Values.ToDictionary(e => e.Context, e => new ParseErrorElement(e.Expected.ToHashSet(), e.Context)); foreach (var element in second.Elements.Values) { if (elements.TryGetValue(element.Context, out var part)) { - foreach (var e in element.Expected) part.Add(e); + foreach (var e in element.Expected) part.Expected.Add(e); } else { - part = element.Expected.ToHashSet(); + part = new (element.Expected.ToHashSet(), element.Context); elements.Add(element.Context, part); } } @@ -84,7 +84,7 @@ private ParseError(IReadOnlyDictionary elements, obje // Since position is here now, Got is kind of a utility we have here, we could just aswell have a // 'reason' for each element return new( - elements.ToDictionary(kv => kv.Key, kv => new ParseErrorElement(kv.Value, kv.Key)), + elements, first.Got ?? second.Got, first.Position); }