Closed JonathanFoo0523 closed 1 month ago
This is a tough one. It would seem rather restrictive to never mutate the initializer expressions for constants just in case they are used as sizes for arrays. But understanding which constants are used for such purposes could be difficult.
In the AST (obtained using --dump-asts
) the array c
has size 2, rather than size b
. It looks like the front-end has rewritten b
as 2. Therefore there's actually no way we can detect this via AST analysis.
One possibility would be to rewrite b
to 2 as part of the mutation process, so that the declared constant b
is decoupled from its use as an array size.
That would be a non-trivial change, though.
Applying dredd to the following file
produce
This result in compilation error: