Skip to content
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

Handle cases where key or payload are subtypes of Integer #20

Merged
merged 4 commits into from
Nov 3, 2023

Conversation

bluesmoon
Copy link
Contributor

Integer values cannot be converted directly to Vector{UInt8}; it requires reinterpret and hton. This MR handles that.

We have separate methods for key and payload so that it can handle all three cases where either one of key or payload are Integers, or both are Integers.

Integer values cannot be converted directly to Vector{UInt8}; it requires `reinterpret` and `hton`. This MR handles that.
@dfdx
Copy link
Owner

dfdx commented Nov 3, 2023

or both are Integers.

Wouldn't this case lead to ambiguity?

julia> foo(x::Integer, y) = "x is int"
foo (generic function with 1 method)

julia> foo(x, y::Integer) = "y is int"
foo (generic function with 2 methods)

julia> foo(x, y) = "x and y are Any"
foo (generic function with 3 methods)

julia> foo(1, 1)
ERROR: MethodError: foo(::Int64, ::Int64) is ambiguous.

Candidates:
  foo(x::Integer, y)
    @ Main REPL[1]:1
  foo(x, y::Integer)
    @ Main REPL[2]:1

Possible fix, define
  foo(::Integer, ::Integer)

Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

@bluesmoon
Copy link
Contributor Author

@dfdx hopefully these updates handle all cases as well as the consumer side.

@dfdx
Copy link
Owner

dfdx commented Nov 3, 2023

Looks great, thank you!

@dfdx dfdx merged commit f62e4f3 into dfdx:master Nov 3, 2023
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 this pull request may close these issues.

None yet

2 participants