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

Fix ambiguous call with untyped int literal in {JSON,YAML}::Any.new #13618

Merged
merged 3 commits into from Jul 7, 2023

Conversation

straight-shoota
Copy link
Member

Adds a workaround for #11645

@HertzDevil
Copy link
Contributor

Do you think we also need similar overloads for the smaller integer types?

@straight-shoota
Copy link
Member Author

Perhaps. But the main intention is to get it working with untyped literals.
Ideal solution would be fixing the autocasting.

@HertzDevil
Copy link
Contributor

I don't think we need to restrict ourselves to the number types supported by the Anys, instead we could just support all of them:

def initialize(@raw : Type)
end

# this overload goes below the `Type` one to avoid an infinite recursion,
# as the two overloads are unordered
def self.new(raw : Int)
  new(raw.to_i64)
end

def self.new(raw : Float)
  new(raw.to_f64)
end

@straight-shoota straight-shoota added this to the 1.9.0 milestone Jul 5, 2023
@straight-shoota straight-shoota merged commit 3268c81 into crystal-lang:master Jul 7, 2023
52 checks passed
@straight-shoota straight-shoota deleted the fix/any-int branch July 7, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants