When tmp1 is defined globally, dmd is doing something different, in some way it sees global immutables almost as enums... I don't know if this is present in D specs.
You see it well with this test program:
immutable int[] A = [1]; template Foo(size_t n) {} void main() { alias Foo!(A.length) fooA; // OK enum int[] B = [1]; alias Foo!(B.length) fooB; // OK immutable int[] C = [1]; alias Foo!(C.length) fooC; // error } Bye, bearophile