TimLariviere / Fabulous-new

Fabulous v2 - Work in progress
https://timothelariviere.com/Fabulous-new/
Other
41 stars 3 forks source link

[Bug] Diffing ScalarAttributes can lead to IndexOutOfRange #104

Closed TimLariviere closed 2 years ago

TimLariviere commented 2 years ago

There is a bug when we remove some attributes and add new ones from a control that is reused by Fabulous. It is specific when the removed attributes have a higher "key" than the new "ones", and there is more new ones than old ones.

It's quite difficult to explain, but here is a repro:

let Attr1 = Attributes.define ... // Key = 0
let Attr2 = Attributes.define ... // Key = 1
let Attr3 = Attributes.define ... // Key = 2
let Attr4 = Attributes.define ... // Key = 3
let Attr5 = Attributes.define ... // Key = 4

if not model.Flag then
    Button()
        .attr4()
        .attr5()

else
    Button()
        .attr1()
        .attr2()
        .attr3()

// Start: model.Flag = false
// When switching model.Flag to true, an index out of range exception is raised inside ScalarAttributesChangesEnumerator