-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some arithmetic invalidations #37820
Conversation
Doctest failure looks related. Will investigate. Stacktrace: ERROR: LoadError: TypeError: in typeassert, expected UInt64, got a value of type Int64
Stacktrace:
[1] writeshortest(buf::Vector{UInt8}, pos::Int64, x::Float64, plus::Bool, space::Bool, hash::Bool, precision::Int64, expchar::UInt8, padexp::Bool, decchar::UInt8, typed::Bool, compact::Bool)
@ Base.Ryu ./ryu/shortest.jl:387
[2] show(io::IOContext{IOBuffer}, x::Float64, forceuntyped::Bool, fromprint::Bool)
@ Base.Ryu ./ryu/Ryu.jl:115
[3] show(io::IOContext{IOBuffer}, x::Float64)
... |
base/strings/string.jl
Outdated
@@ -92,7 +92,7 @@ String(s::CodeUnits{UInt8,String}) = s.s | |||
## low-level functions ## | |||
|
|||
pointer(s::String) = unsafe_convert(Ptr{UInt8}, s) | |||
pointer(s::String, i::Integer) = pointer(s)+(i-1) | |||
pointer(s::String, i::Integer) = pointer(s) + (i - 1)::Integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes these are written as Int(i)::Int - 1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any concern about having values too large to convert to an Int
? It seems unlikely that would occur but I figured I'd ask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd think string length is pretty safe; someone would need to have a single string that's more than half the size of memory on a 32-bit machine. I guess you could alternatively use UInt
.
72ebdec
to
a0f4c34
Compare
I think there is nothing left to do here. I'll wait to merge until I get approval |
While investigating invenia/Intervals.jl#144 I noticed these invalidations:
The use of
Any
stuck out to me so I looked into these and the changes PR was is the result. With these changes this invalidations no longer exist. Please let me know if I'm off base here as I am new to addressing invalidations.