env.cpp: correctly check variable_can_be_array

Closes #1746.