-
Notifications
You must be signed in to change notification settings - Fork 28
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
Improve inference #111
Improve inference #111
Conversation
LGTM |
Sorry, I'm not sure what problem this pull request will fix. Can you share a case annoying you? |
It's a matter of inference and linting - behaviour is already correct. Here is a minimal example: julia> using CodecZlib, JET
julia> @report_call GzipCompressorStream(IOBuffer())
═════ 1 possible error found ═════
┌ @ /home/jakob/.julia/packages/CodecZlib/ruMLE/src/compression.jl:48 CodecZlib.#GzipCompressorStream#2(Base.pairs(Core.NamedTuple()), #self#, stream)
│┌ @ /home/jakob/.julia/packages/CodecZlib/ruMLE/src/compression.jl:49 Core.kwfunc(CodecZlib.TranscodingStream)(Base.merge(Base.NamedTuple(), y), CodecZlib.TranscodingStream, _8, stream)
││┌ @ /home/jakob/.julia/packages/TranscodingStreams/MsN8d/src/stream.jl:118 TranscodingStreams.#TranscodingStream#5(bufsize, stop_on_end, sharedbuf, _3, codec, stream)
│││┌ @ /home/jakob/.julia/packages/TranscodingStreams/MsN8d/src/stream.jl:121 Base.getproperty(stream, :state)
││││┌ @ Base.jl:42 Base.getfield(x, f)
│││││ type IOBuffer has no field state
││││└──────────────
TranscodingStreams.TranscodingStream{GzipCompressor, IOBuffer} As Julia linting and analysis gets better and better, this code part will keep showing up. |
Hm, although perhaps this inference will actually be solved by JuliaLang/julia#40880 - not sure! |
Thank you for explanation. In general, I don't like the idea of introducing annotation code for specific tools, especially if it is a false alarm. But if this change has large benefits to you and others, I'd say it's fine. Is this a must-have change, or a nice-to-have one? |
I completely get what you mean. It is not a good idea to change package X just so it works better with package Y. Because there can be a huge number of other packages that then may need changes to package X. However, in this case, it's a bit different, I think, because it is really a kind of "type instability", or at least a mild inference issue. It's not JET.jl that thinks that the The problem is that, as far as I can tell, the value of |
OK, then, let's annotate the code. But before merging, can you add a comment that refers to this pull request so that we don't miss the reason why the annotation is introduced. Git blame is not reliable for that purpose IMO. |
If one constructs a
TranscodingStream
and setssharedbuf
, the input must also be aTranscodingStream
. The compiler now checks it. Previously, this would show up as a potential error in linters and such.