oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3.02k stars 185 forks source link

File#each_line doesn't accept chomp: true #2650

Closed zofrex closed 2 years ago

zofrex commented 2 years ago

Possibly similar to #2205?

> File.open('/dev/null').each_line(chomp: true).first
<internal:core> core/type.rb:104:in `coerce_to_failed': wrong argument type Hash (expected Integer) (TypeError)
    from <internal:core> core/type.rb:93:in `execute_coerce_to'
    from <internal:core> core/type.rb:85:in `coerce_to'
    from <internal:core> core/io.rb:1354:in `create_each_reader'
    from <internal:core> core/io.rb:1369:in `each'
    from <internal:core> core/enumerator.rb:103:in `each_with_block'
    from <internal:core> core/enumerator.rb:94:in `each'
    from <internal:core> core/enumerable.rb:715:in `first'
    from (irb):1:in `<top (required)>'
<internal:core> core/type.rb:91:in `execute_coerce_to': undefined method `to_int' for {:chomp=>true}:Hash (NoMethodError)
Did you mean?  to_set
               taint
    from <internal:core> core/type.rb:85:in `coerce_to'
    from <internal:core> core/io.rb:1354:in `create_each_reader'
    from <internal:core> core/io.rb:1369:in `each'
    from <internal:core> core/enumerator.rb:103:in `each_with_block'
    from <internal:core> core/enumerator.rb:94:in `each'
    from <internal:core> core/enumerable.rb:715:in `first'
    from (irb):1:in `<top (required)>'
eregon commented 2 years ago

@bjfish It'd be a good idea to search for getline_args in CRuby and see if TruffleRuby accepts chomp: for all such methods in CRuby to ensure we don't miss any other.

eregon commented 2 years ago

Actually, let's leave this one to @andrykonchin :)

andrykonchin commented 2 years ago

Fixed in b30242d07e2b6d471cefdbef020b5b0daf4b8a99, thank you for the report.