Test var before using as array. Should fix #2794