The compiler analyzes expressions recusively. Large expressions consume large
amounts of stack space. Very large expressions can cause the compiler to
overflow the stack, which results in a seg fault.
I fixed this by imposing a limit of 1000 for the depth of the expression tree
analyzed by the compiler. Upon reaching this limit, the compiler will emit a
message, unwind from the analysis of that expression, and proceed with the rest
of the compilation.
The limit of 1000 is a little arbitrary. I experimentally verified that the
compiler cannot handle a limit of 5000, and 1000 seems big enough.
I added a test that will produce a seg fault without this change. It also
contains an expression with 1000 operations that gets constant folded. This
demonstrates that, if we can analyze an expression, we can fold it. I also
included two cases where we create array constructors of many more elements
than the expression limit to verify that we can handle large array
constructors.