-
Notifications
You must be signed in to change notification settings - Fork 844
Closed
Description
This being a container for a source string, while identical SourceTexts will have the same hash code, it fails for equality testing because a StringText object is compared to the other's source text, which is always false.
The implementation in prim-lexing.fs:
override __.GetHashCode() = str.GetHashCode()
override __.Equals(obj: obj) = str.Equals(obj)
This behavior breaks dictionaries and sets.
Repro:
let text = "()"
let source1 = FSharp.Compiler.Text.SourceText.ofString text
let source2 = FSharp.Compiler.Text.SourceText.ofString text
assert(source1.GetHashCode() = source2.GetHashCode()) //works
assert(source1 = source2) //fails
auduchinok