Skip to content

ternary operator in package code results in MethodError #28637

@phaverty

Description

@phaverty

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions