JeffreySarnoff / SaferIntegers.jl

These integer types use checked arithmetic, otherwise they are as system types.
MIT License
59 stars 10 forks source link

saferintegers macro fails with ^ operator #35

Closed Tortar closed 1 year ago

Tortar commented 1 year ago

I was playing with the saferintegers macro to see it in action but something strange occurred:

julia> using SaferIntegers
julia> @saferintegers 100^1

ERROR: LoadError: UndefVarError: ChangeType not defined
Stacktrace:
 [1] changetypes(ex::Expr)
   @ SaferIntegers.SaferIntTypes ~/.julia/packages/SaferIntegers/Xn8ie/src/SaferIntTypes.jl:83
 [2] changetype(ex::Expr)
   @ SaferIntegers.SaferIntTypes ~/.julia/packages/SaferIntegers/Xn8ie/src/SaferIntTypes.jl:75
 [3] var"@saferintegers"(__source__::LineNumberNode, __module__::Module, x::Any)
   @ SaferIntegers.SaferIntTypes ~/.julia/packages/SaferIntegers/Xn8ie/src/SaferIntTypes.jl:170
in expression starting at REPL[35]:1

I'm using Julia 1.8

I read the documentation and tested the above calculation replacing ^ with other operators (*,-, mod,...), they seemed to work fine, is there a reason why this instead fails? This seems like a bug to me. Not sure but it seems like a compatibilty problem with newer versions of Julia even if I didn't have the time to try it out on some older version yet. Hope this helps!

Tortar commented 1 year ago

Solved in #36