Skip to content

Commit 24324fb

Browse files
committed
fix#1500: строгое сравнение значений при поиске
1 parent 12bca1e commit 24324fb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/OneScript.Core/Values/IValue.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ public interface IValue : IComparable<IValue>, IEquatable<IValue>
1818
IValue GetRawValue();
1919
}
2020

21+
public static class IValueExtension
22+
{
23+
public static bool StrictEquals(this IValue value, IValue other)
24+
=> value.Equals(other) && value.SystemType == other.SystemType;
25+
}
2126
}

src/OneScript.StandardLibrary/Collections/ArrayImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void Insert(int index, IValue value = null)
113113
[ContextMethod("Найти", "Find")]
114114
public IValue Find(IValue what)
115115
{
116-
var idx = _values.FindIndex(x => x.Equals(what));
116+
var idx = _values.FindIndex(x => x.StrictEquals(what));
117117
if(idx < 0)
118118
{
119119
return ValueFactory.Create();

0 commit comments

Comments
 (0)