Fix mismatch in substr between const folded and dynamically run