dplassgit / d2lang

D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
MIT License
6 stars 0 forks source link

ConstantPropagationOptimizer is incorrectly propagating a value that has changed #360

Closed dplassgit closed 2 weeks ago

dplassgit commented 2 weeks ago
buffering=0

setBuffering(newval: INT): int {
  oldbuffering = buffering
  buffering = newval
  return oldbuffering

Is being optimized to

setBuffering(newval: INT):int {
   oldbuffering = buffering
   buffering = newval
   return buffering // THIS IS WRONG
dplassgit commented 2 weeks ago

Probably still broken for binary ops