With #1744 we introduced code which unrolls constructors of huge containers. The code we now generate is incorrect for const variables which do not live in a scope (it does work for globals though which are managed more thightly by the module).
module foo;
# Ctrs for collections of more than 10 elements get unrolled.
const CRC16_TABLE: vector<uint16> = [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
];
We probably need to adjust or even drop the capture for declarations emitted outside of a proper C++ scope. ~We still need to make sure that a constructor can reference other const variables though.~ A declaration of a const can only refer to other const variables; since const variables are emitted as non-local variables we do not need to capture them.
With #1744 we introduced code which unrolls constructors of huge containers. The code we now generate is incorrect for
const
variables which do not live in a scope (it does work forglobal
s though which are managed more thightly by the module).We probably need to adjust or even drop the capture for declarations emitted outside of a proper C++ scope. ~We still need to make sure that a constructor can reference other
const
variables though.~ A declaration of aconst
can only refer to otherconst
variables; sinceconst
variables are emitted as non-local variables we do not need to capture them.