On Mon, Aug 10, 2020 at 1:02 AM Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum 10353@lyskom.lysator.liu.se wrote:
4^-2 is not an integer. It's 0.0625 (or 1/16, if expressed as a fraction, which seems to be what 8.1 has chosen here).
True. In the original, though, this was guarded such that this expression would only ever have a positive exponent. I couldn't figure out a way to force STR to be interpreted as int(2..) though.
The original was more like this, but the effect is the same:
calc("STR < 2 ? STR : 4 ** (STR - 2)");
In theory, static analysis should show that the exponent has to be 0 or greater, but if it can't figure that out, I'd be okay with telling it that (eg with a cast). Attempting to add the cast just produces a warning "Soft cast of zero to int(2..) is a noop" and the same exception.
ChrisA
pike-devel@lists.lysator.liu.se