Erratic failure to specialize function