fix: miscompilation in constant folding

closes #4306
2 files changed