Skip to content

Exception when use Array#join after Array#slice #239

@sobrinho

Description

@sobrinho

This issue is affecting I18n::Cascade, see ruby-i18n/i18n#156

I reproduced the issue on irb:

[:something, :wrong].slice(-1, 1).join(".")
# TypeError: can't convert Symbol into String
#   from org/jruby/RubyArray.java:1871:in `join'
#   from (irb):2:in `evaluate'
#   from org/jruby/RubyKernel.java:1088:in `eval'
#   from org/jruby/RubyKernel.java:1410:in `loop'
#   from org/jruby/RubyKernel.java:1197:in `catch'
#   from org/jruby/RubyKernel.java:1197:in `catch'

[:something, :wrong].slice(-1, 1)
#=> [:wrong]

[:wrong].join(".")
#=> "wrong"

Calling Array#join on an Array#slice result, throws the exception.

Using a variable, I get the same issue:

data = [:something, :wrong].slice(-1, 1)
#=> [:wrong]

data.join(".")
# TypeError: can't convert Symbol into String
#   from org/jruby/RubyArray.java:1871:in `join'
#   from (irb):7:in `evaluate'
#   from org/jruby/RubyKernel.java:1088:in `eval'
#   from org/jruby/RubyKernel.java:1410:in `loop'
#   from org/jruby/RubyKernel.java:1197:in `catch'
#   from org/jruby/RubyKernel.java:1197:in `catch'

I'm not sure but seems like something related to slice result.

Anyway, comparing the slice result with plain array, I get true:

[:something, :wrong].slice(-1, 1) == [:wrong]
#=> true

I don't know the jruby core but I will look tomorrow :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions