c3 does this automatically, I implemented the same thing :)

https://github.com/c3lang/c3c/pull/2854