Commit dcf67df
committed
Fix pow(x, 1/2) -> sqrt(x) miscompilation for integer division
When both operands in the exponent division are UInt, Stan performs
integer division (1/2 = 0), so pow(x, 1/2) is actually pow(x, 0) = 1.
The partial evaluator was incorrectly rewriting this to sqrt(x).
Add a type check to the guard so the simplification only fires when
at least one operand is real (i.e., actual floating-point division).
Also removes the comment that was flagging this as a known bug.
Add test case for pow(theta, 1/2) with pure integer literals.1 parent ae477a5 commit dcf67df
2 files changed
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
707 | | - | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
708 | 710 | | |
709 | 711 | | |
710 | | - | |
711 | | - | |
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2171 | 2171 | | |
2172 | 2172 | | |
2173 | 2173 | | |
| 2174 | + | |
2174 | 2175 | | |
2175 | 2176 | | |
2176 | 2177 | | |
| |||
2338 | 2339 | | |
2339 | 2340 | | |
2340 | 2341 | | |
| 2342 | + | |
2341 | 2343 | | |
2342 | 2344 | | |
2343 | 2345 | | |
| |||
0 commit comments