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

<< StackOverflowError instead of MethodError #30197

Closed
goretkin opened this issue Nov 29, 2018 · 1 comment
Closed

<< StackOverflowError instead of MethodError #30197

goretkin opened this issue Nov 29, 2018 · 1 comment

Comments

@goretkin
Copy link
Contributor

goretkin commented Nov 29, 2018

The definition

<<(x::Integer, c::Unsigned) = c <= typemax(UInt) ? x << (c % UInt) : zero(x)

<<(x::Integer, c::Unsigned) = c <= typemax(UInt) ? x << (c % UInt) : zero(x)

loops. For example

julia> using GeometryTypes
julia> OffsetInteger{-1}(3) << UInt(2)
ERROR: StackOverflowError:
Stacktrace:
 [1] <<(::OffsetInteger{-1,Int64}, ::UInt64) at ./operators.jl:568 (repeats 80000 times)

or, self-contained

julia> struct A <: Integer
       end

julia> A() << UInt(2)
ERROR: StackOverflowError:
Stacktrace:
 [1] <<(::A, ::UInt64) at ./operators.jl:568 (repeats 80000 times)

Obviously, to get << working, I need to define an additional method, which would be more specific and prevent infinite recursion. So I'm not sure if this counts as a bug. Making an issue just in case there's a way to fix it to get a MethodError instead.

Related: #26552

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
@vtjnash
Copy link
Member

vtjnash commented Mar 15, 2021

Fixed by 9562bdf (#30906)

@vtjnash vtjnash closed this as completed Mar 15, 2021
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

No branches or pull requests

2 participants