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 error messages for ranges with missing #46245

Open
bkamins opened this issue Aug 3, 2022 · 2 comments
Open

Fix error messages for ranges with missing #46245

bkamins opened this issue Aug 3, 2022 · 2 comments
Labels
domain:error messages Better, more actionable error messages domain:missing data Base.missing and related functionality

Comments

@bkamins
Copy link
Member

bkamins commented Aug 3, 2022

@nalimilan - this is a common error.

First a case when I think error message is OK (or at least acceptable):

julia> missing:1:missing
ERROR: TypeError: non-boolean (Missing) used in boolean context

Now a case when new users will be confused:

julia> missing:0.1:missing
ERROR: ArgumentError: StepRange should not be used with floating point

Source why it is common:

julia> x = [missing, 1.1, 0.3]
3-element Vector{Union{Missing, Float64}}:
  missing
 1.1
 0.3

julia> minimum(x):0.1:maximum(x) # clearly skipmisssing should be used but it is not obvious to the user
ERROR: ArgumentError: StepRange should not be used with floating point
@nalimilan nalimilan added domain:missing data Base.missing and related functionality domain:error messages Better, more actionable error messages labels Aug 3, 2022
@nalimilan
Copy link
Member

Good point. I'd say that the problem here is that the x:y:z syntax dispatches to StepRange despite the fact that y is floating point. An error should probably be thrown earlier, without mentioning StepRange, since the user didn't ask for it at any point. Printing the type of all three values would help users understand the problem.

@bkamins
Copy link
Member Author

bkamins commented Aug 3, 2022

Yes, the reason is that the method upstream expects x and z to have the same type only.
Most likely we need to add a method with Missing being a specific type and throw an error in that case.
BTW a related issue is #46244.

Note that also:

julia> 0.1:0.1:missing
ERROR: MethodError: no method matching (::Colon)(::Float64, ::Float64, ::Missing)

is I think OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:error messages Better, more actionable error messages domain:missing data Base.missing and related functionality
Projects
None yet
Development

No branches or pull requests

2 participants