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

ternary operator in package code results in MethodError #28637

Closed
phaverty opened this issue Aug 13, 2018 · 2 comments
Closed

ternary operator in package code results in MethodError #28637

phaverty opened this issue Aug 13, 2018 · 2 comments

Comments

@phaverty
Copy link
Contributor

phaverty commented Aug 13, 2018

Using julia 0.7 on a Mac, functions containing a ternary operator seem to generate a MethodError:

julia> @test ind2runcontext(RLEVector([3,3,4,4,5,5,6,6,7,7]),5) == (3,1,1)                                                                                                     
 Error During Test at none:1
   Test threw exception MethodError(RLEVectors.==, (3, 1), 0x0000000000006c6c)
   Expression: ind2runcontext(RLEVector([3, 3, 4, 4, 5, 5, 6, 6, 7, 7]), 5) == (3, 1, 1)
   MethodError: no method matching ==(::Int64, ::Int64)
   You may have intended to import Base.==
   Stacktrace:
    [1] ind2runcontext(::RLEVector{Int64,Int64}, ::Int64) at /Users/phaverty/BioJulia/dev/RLEVectors/src/indexing.jl:46
    [2] top-level scope at none:0
    [3] eval(::Module, ::Any) at ./boot.jl:319
    [4] eval_user_input(::Any, ::REPL.REPLBackend) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:85
    [5] macro expansion at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:117 [inlined]
    [6] (::getfield(REPL, Symbol("##28#29")){REPL.REPLBackend})() at ./task.jl:262
 ERROR: There was an error during testing

This has happened with a few functions containing ternary operator code and only in such functions. Oddly, this seems isolated to loading package code. When these functions are re-entered at the REPL, they work fine.

In this case the ternary operator line is
ind_in_run = run == 1 ? i : i - rle.runends[run - 1]

Perhaps this is related to the new parsing rules for the ternary operator? (#22523 and #22712) These functions worked without trouble on julia 0.6.x

julia> versioninfo()
 Julia Version 0.7.0
 Commit a4cb80f3ed (2018-08-08 06:46 UTC)
 Platform Info:
   OS: macOS (x86_64-apple-darwin14.5.0)
   CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
   WORD_SIZE: 64
   LIBM: libopenlibm
   LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
 Environment:
   JULIA_HOME = /Applications/Julia-0.6.app/Contents/Resources/julia/bin

I hope this is enough information to go on. Please let me know if I can provide something else.

@fredrikekre
Copy link
Member

RLEVectors.==

and

You may have intended to import Base.==

seems to indicate that you may have defined your own module local version of == that indeed does not accept two Ints. Might that be the case?

@phaverty
Copy link
Contributor Author

Yes, thank you! I dropped the import/export for == unintentionally. Your quick response was extremely helpful, thanks!

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