I've been using the combination
ConstantArray[0, {}]
(* 0 *)
in my code for some time, as a way for returning zero (i.e. a zero-dimensional array of zeroes) inside scalable code that can be made to produce empty arrays of arbitrary dimensions but also zeros. On my system (currently v11 over linux) it's always worked well since I introduced it.
However, when I tried to run the same code on other systems, you sometimes get the following:
ConstantArray[0, {}] ConstantArray::ilsmn : Single or list of non-negative machine-sized integers expected at position 2 of ConstantArray[0, {}]
(*Out[]:= ConstantArray[0, {}]*)
The above screenshot was taken over version 10 on OSX; a separate user also observed this in v8 over Windows 7.
I find this confusing, and I'm pretty sure it's a bug. In particular, the documentation for ConstantArray claims that its history is
Introduced in 2007 (6.0) | Updated in 2008 (7.0)
which means that there should be no change between v8 and v11. I will file a bug report shortly, but mostly I would like to build a workaround (since I want my code to be usable on systems like e.g. v10/OSX). At present, thus, my main question is: on which systems does this behaviour show up, and on which ones does it return a plain 0
without complaints? I suspect this depends both on the specific version and the operating system, but it'd be nice to know for sure.