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

Throw on non-promotion in fallback UnitRange constructor #50292

Merged
merged 2 commits into from
Jun 27, 2023

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Jun 26, 2023

This avoids a StackOverflowError in the fallback UnitRange constructor, and throws an error if the promotion does not change the types of the arguments.

On master

julia> UnitRange('a', 'b')
ERROR: StackOverflowError:
Stacktrace:
 [1] UnitRange(start::Char, stop::Char) (repeats 79984 times)
   @ Base ./range.jl:401

After this

julia> UnitRange('a', 'b')
ERROR: promotion of types Char and Char failed to change any arguments
Stacktrace:
 [1] error(::String, ::String, ::String)
   @ Base ./error.jl:44
 [2] sametype_error(input::Tuple{Char, Char})
   @ Base ./promotion.jl:417
 [3] not_sametype(x::Tuple{Char, Char}, y::Tuple{Char, Char})
   @ Base ./promotion.jl:411
 [4] UnitRange(start::Char, stop::Char)
   @ Base ~/julia/base/range.jl:409
 [5] top-level scope
   @ REPL[9]:1

@jishnub jishnub changed the title Throw on promotion failure in UnitRange Throw on non-promotion in fallback UnitRange constructor Jun 26, 2023
@N5N3 N5N3 merged commit 6f26e4f into JuliaLang:master Jun 27, 2023
@jishnub jishnub deleted the UnitRangepromote branch June 27, 2023 14:34
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.

3 participants