Skip to content

Proc#source_location returns something different but in MRI  #1663

@deepj

Description

@deepj

I guess, TruffleRuby behaviour is correct in this point

fn = :itself.to_proc
fn.source_location

TruffleRuby 1.0.0 RC15

# => ["proc-source_location.rb", 1]

MRI 2.6.2

# => nil

This difference causes a problem in the following dry-types logic here https://github.com/dry-rb/dry-types/blob/master/lib/dry/types/printer.rb#L255

Due this, this spec fails on

$ bundle exec rspec ./spec/dry/types/hash_spec.rb:56
Run options: include {:locations=>{"./spec/dry/types/hash_spec.rb"=>[56]}}

Randomized with seed 19003
F

Failures:

  1) Dry::Types::Hash#to_s with type transformation returns string representation of the type
     Failure/Error: expect(type.to_s).to eql('#<Dry::Types[Hash<type_fn=.itself>]>')

       expected: "#<Dry::Types[Hash<type_fn=.itself>]>"
            got: "#<Dry::Types[Hash<type_fn=spec/dry/types/hash_spec.rb:53>]>"

       (compared using eql?)
     # ./spec/dry/types/hash_spec.rb:56:in `block (4 levels) in <top (required)>'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/cli/exec.rb:74:in `load'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/cli/exec.rb:74:in `load'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/cli/exec.rb:74:in `kernel_load'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/cli/exec.rb:28:in `run'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/cli.rb:463:in `exec'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/cli.rb:27:in `dispatch'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/cli.rb:18:in `start'
     # ~/.rubies/truffleruby-1.0.0-rc15/lib/mri/bundler/friendly_errors.rb:124:in `with_friendly_errors'

Finished in 0.166 seconds (files took 4.2 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/dry/types/hash_spec.rb:55 # Dry::Types::Hash#to_s with type transformation returns string representation of the type

Randomized with seed 19003

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions