fabulous-dev / Fabulous

Declarative UI framework for cross-platform mobile & desktop apps, using MVU and F# functional programming
https://fabulous.dev
Apache License 2.0
1.14k stars 121 forks source link

IndexOutOfRangeException' in Fabulous.XamarinForms.Collections.deleteAt #861

Closed marklam closed 3 years ago

marklam commented 3 years ago

Description

The upper bound at https://github.com/fsprojects/Fabulous/blob/c442b48c9e30bad413948298b5bee1be2a455291/Fabulous.XamarinForms/src/Fabulous.XamarinForms/Collections.fs#L41-L42 is too high, and the arr.[i + 1] will attempt to read outside the array.

Steps to Reproduce

Happens from Collections.diff at https://github.com/fsprojects/Fabulous/blob/c442b48c9e30bad413948298b5bee1be2a455291/Fabulous.XamarinForms/src/Fabulous.XamarinForms/Collections.fs#L140 with a 16-element array, reusableIndex = 0 reusableElementsCount = 16, discardedElementsCount = 0, identicalElements is empty.

Expected Behavior

Item is removed

Actual Behavior

Exception is thrown, and swallowed by WPF

Basic Information

TimLariviere commented 3 years ago

@marklam Thanks for the precise report It helped me find the real reason why we did not see it before, and write a unit test to catch this specific case. I will release a new version with this fix.