core: fix unboxing where primop returns a value type