Skip to content

TypeError: "warn" with subclass of String constructed from heredoc #5935

@buehmann

Description

@buehmann

Environment

$ jruby -v
jruby 9.2.8.0 (2.5.3) 2019-08-12 a1ac7ff OpenJDK 64-Bit Server VM 13+33 on 13+33 +jit [darwin-x86_64]
$ uname -a
Darwin mb204.fidor.loc 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64 i386 MacBookPro15,1 Darwin

Expected Behavior

The script

S = Class.new(String)

warn S.new("foo")
warn S.new(<<M)
bar
M

is expected to output

foo
bar

to stderr.

Actual Behavior

Instead JRuby raises a TypeError for the second warning (heredoc case):

foo
TypeError: wrong argument type S (expected String)
    warn at org/jruby/common/RubyWarnings.java:224
  <main> at jruby-bug.rb:4

This was originally observed with the rainbow gem (https://github.com/sickill/rainbow) here: https://circleci.com/gh/rubocop-hq/rubocop/72166

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions