Amazing discoveries. And even this does not compile outside of the function. But it does inside:
// breaks
let {a, b} = Definition.getRecord()
let doIt = () => {
// compiles
let {a, b} = Definition.getRecord()
}
This feels even a bigger contradiction to me, and it only involves records, no lists.
That said, I encounter many cases where accessing a record field (or decomposition) fails to compile and needs a type hint. But the type should otherwise be known at that point. I intuitively feel that these should all compile. But I cannot wrap my head around it what exactly is happening here.
I’ll think about this further. Meanwhile, if anyone knows the reason… please do tell! 