Advice to make getfield(::NamedTuple, ::Symbol) typestable

@code_warntype is misleading you here. This is exactly the same issue as trying to do @code_warntype pair.first here: Accessing the field of `Pair` seems to be type-unstable - #4 by rdeits

Edit: Although if you really are passing a Symbol down from your outermost function, then the type instability is real (even if your first example doesn’t necessarily show it). If that’s the case, then the Val approach seems reasonable to me.

1 Like