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

Isolate the case where the argument is Integer in the rand method #1982

Conversation

rhiroe
Copy link

@rhiroe rhiroe commented Aug 24, 2024

Because it always returns Integer for non-zero integer values.

Background

1 + rand(10)

Running steep check, this causes UnresolvedOverloading.

Integer + (Integer | Float)

Writing an expression like this seems to cause UnresolvedOverloading.

Although not a direct solution, this problem can be avoided if the possibility of a Float being returned when the argument is a non-zero integer can be eliminated.

Thank you.

Because it always returns Integer for non-zero integer values.
@ParadoxV5
Copy link
Contributor

0 is still an Integer. To support the concept of non-zero, we’d need #1875.

It’s strange, however, that this situation leads to UnresolvedOverloading. Integer should be able to + either Integer or Float.

Integer + (Integer | Float) -> (Integer | Float)

@rhiroe
Copy link
Author

rhiroe commented Aug 24, 2024

@ParadoxV5

0 is still an Integer

You are right.
However, if the argument is 0, Float is returned here.

def self?.rand: (?0) -> Float

Thus, Integer here should come to a non-zero integer, right?
| (Integer arg0) -> Integer

@ParadoxV5
Copy link
Contributor

It should, but it doesn’t. That’s what #1875 was about.

@rhiroe
Copy link
Author

rhiroe commented Aug 25, 2024

It made sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants