Skip to content

transcode(::Type{CodecZlib.GzipCompressor}, ::String) is ambiguous on v0.9.12 #139

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

Closed
felipenoris opened this issue Apr 11, 2023 · 2 comments · Fixed by #141
Closed

transcode(::Type{CodecZlib.GzipCompressor}, ::String) is ambiguous on v0.9.12 #139

felipenoris opened this issue Apr 11, 2023 · 2 comments · Fixed by #141

Comments

@felipenoris
Copy link

Hello! I'm getting this error after updating TranscodingStreams to v0.9.12.

(@v1.7) pkg> add CodecZlib
   Resolving package versions...
    Updating `~/.julia/environments/v1.7/Project.toml`
  [944b1d66] + CodecZlib v0.7.1
    Updating `~/.julia/environments/v1.7/Manifest.toml`
  [944b1d66] + CodecZlib v0.7.1
  [3bb67fe8] + TranscodingStreams v0.9.12

julia> import CodecZlib

julia> CodecZlib.transcode(CodecZlib.GzipCompressor, "hey ya")
ERROR: MethodError: transcode(::Type{CodecZlib.GzipCompressor}, ::String) is ambiguous. Candidates:
  transcode(T, src::String) in Base at c.jl:291
  transcode(::Type{C}, args...) where C<:TranscodingStreams.Codec in TranscodingStreams at /home/fnoro/.julia/packages/TranscodingStreams/5yQuA/src/transcode.jl:33
Possible fix, define
  transcode(::Type{C}, ::String) where C<:TranscodingStreams.Codec
Stacktrace:
 [1] top-level scope
   @ REPL[5]:1
@felipenoris
Copy link
Author

felipenoris commented Apr 13, 2023

As a workaround, one can use:

julia> CodecZlib.transcode(CodecZlib.GzipCompressor, Vector{UInt8}("hey ya"))
26-element Vector{UInt8}:
 0x1f
 0x8b
 0x08
 0x00
 0x00
 0x00
 0x00
 0x00
 0x00
 0x03
 0xcb
 0x48
 0xad
 0x54
 0xa8
 0x4c
 0x04
 0x00
 0x2e
 0xee
 0x85
 0xee
 0x06
 0x00
 0x00
 0x00

@bauglir
Copy link
Contributor

bauglir commented Apr 13, 2023

This appears to be caused by changes introduced in #136, specifically this signature change.

Although passing a string directly as the second argument to transcode does not appear to be documented as a valid API in this package's README. All the linked codec packages, like the mentioned CodecZLib, document that passing a string should work.

Was the removal of this API intentional? If so the release v0.9.12 release should probably have been a minor release instead of a patch release. Mostly looking for an answer as to whether this is something that consuming packages should update or whether the ambiguity will be/should be resolved here. I'm not sure if the splatted args can be typed to resolve the ambiguity.

bauglir added a commit to bauglir/TranscodingStreams.jl that referenced this issue Apr 14, 2023
The examples in many of the codec packages rely on being able to call
`transcode` providing a `Codec` type and a string[^1][^2]. JuliaIO#132 removed
type annotations from the trailing arguments for `transcode(::Type{C},
...) where {C<:Codec}` causing a method ambiguity with `transcode(T,
src::String)` in Julia `Base`[^3]. This adds an additional method to
`Base.transcode` to resolve this ambiguity.

Fixes JuliaIO#139.

[^1]: https://github.com/JuliaIO/CodecZlib.jl/tree/f9fddaa28c093c590a7a93358709df2945306bc7#usage
[^2]: https://github.com/JuliaIO/CodecZstd.jl/tree/6327ffa9a3a12fc46d465dcfc8b30bed91cf284b#usage
[^3]: https://github.com/JuliaLang/julia/blob/ff7b8eb00bf887f20bf57fb7e53be0070a242c07/base/c.jl#L306
bauglir added a commit to bauglir/TranscodingStreams.jl that referenced this issue Apr 14, 2023
The examples in many of the codec packages rely on being able to call
`transcode` providing a `Codec` type and a string[^1][^2]. JuliaIO#136 removed
type annotations from the trailing arguments for `transcode(::Type{C},
...) where {C<:Codec}` causing a method ambiguity with `transcode(T,
src::String)` in Julia `Base`[^3]. This adds an additional method to
`Base.transcode` to resolve this ambiguity.

Fixes JuliaIO#139.

[^1]: https://github.com/JuliaIO/CodecZlib.jl/tree/f9fddaa28c093c590a7a93358709df2945306bc7#usage
[^2]: https://github.com/JuliaIO/CodecZstd.jl/tree/6327ffa9a3a12fc46d465dcfc8b30bed91cf284b#usage
[^3]: https://github.com/JuliaLang/julia/blob/ff7b8eb00bf887f20bf57fb7e53be0070a242c07/base/c.jl#L306
bauglir added a commit to bauglir/TranscodingStreams.jl that referenced this issue Apr 15, 2023
The examples in many of the codec packages rely on being able to call
`transcode` providing a `Codec` type and a string[^1][^2]. JuliaIO#136 removed
type annotations from the trailing arguments for `transcode(::Type{C},
...) where {C<:Codec}` causing a method ambiguity with `transcode(T,
src::String)` in Julia `Base`[^3]. This adds an additional method to
`Base.transcode` to resolve this ambiguity.

Fixes JuliaIO#139.

[^1]: https://github.com/JuliaIO/CodecZlib.jl/tree/f9fddaa28c093c590a7a93358709df2945306bc7#usage
[^2]: https://github.com/JuliaIO/CodecZstd.jl/tree/6327ffa9a3a12fc46d465dcfc8b30bed91cf284b#usage
[^3]: https://github.com/JuliaLang/julia/blob/ff7b8eb00bf887f20bf57fb7e53be0070a242c07/base/c.jl#L306
mkitti pushed a commit that referenced this issue Apr 20, 2023
The examples in many of the codec packages rely on being able to call
`transcode` providing a `Codec` type and a string[^1][^2]. #136 removed
type annotations from the trailing arguments for `transcode(::Type{C},
...) where {C<:Codec}` causing a method ambiguity with `transcode(T,
src::String)` in Julia `Base`[^3]. This adds an additional method to
`Base.transcode` to resolve this ambiguity.

Fixes #139.

[^1]: https://github.com/JuliaIO/CodecZlib.jl/tree/f9fddaa28c093c590a7a93358709df2945306bc7#usage
[^2]: https://github.com/JuliaIO/CodecZstd.jl/tree/6327ffa9a3a12fc46d465dcfc8b30bed91cf284b#usage
[^3]: https://github.com/JuliaLang/julia/blob/ff7b8eb00bf887f20bf57fb7e53be0070a242c07/base/c.jl#L306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants