Mapping a 'getter'

I think it has to do with typeof(getfield(::T, ::Symbol)) being impossible in the type domain (for heterogeneous field types) because all that is known about the field is that it is ::Symbol. Constant propagation (or concrete evaluation or some other related concept that is subtly different that I wouldn’t identify correctly) of the specific value of the Symbol is necessary to know which field (and type) is being accessed. If sufficient optimization magic occurs, then this all works out. But broadcasting seems to usually be enough to prevent this.

Or maybe I’m quite wrong as to the technical reason. I just know this can be unreliable because I’ve been bit by it before.

Whatever it is, there’s a related issue #43333. There is a comment there that provides a tad more detail, but I’m not qualified to explain it here.

1 Like