Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sinatra: `caller_locations': wrong number of arguments (given 2, expected 0) (ArgumentError) #1934

Closed
deepj opened this issue Feb 27, 2020 · 2 comments
Assignees
Milestone

Comments

@deepj
Copy link

deepj commented Feb 27, 2020

truffleruby 20.1.0-dev-d6e1b291, like ruby 2.6.5, GraalVM CE Native [x86_64-darwin]

This is minimal reproducible code extracted from ruby_event_store-browser. The problem lies in https://github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L1514 It's in conflict with Kernel.caller_locations. No issue under MRI though.

To reproduce:

gem install sinatra
rackup

config.ru

require 'sinatra/base'

class MyApp < Sinatra::Base
  def self.for(host: nil, path: nil, environment: :production)
    self.tap do |app|
      app.settings.instance_exec do
        set :public_folder, "#{__dir__}/../../../public"
      end
    end
  end
end

run MyApp.for

Error:

~/.gem/truffleruby/2.6.5/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1514:in `caller_locations': wrong number of arguments (given 2, expected 0) (ArgumentError)
	from ~/dev/truffleruby/bugs/sinatra/config.ru:8:in `__dir__'
	from ~/dev/truffleruby/bugs/sinatra/config.ru:8:in `block (2 levels) in for'
	from ~/dev/truffleruby/bugs/sinatra/config.ru:7:in `instance_exec'
	from ~/dev/truffleruby/bugs/sinatra/config.ru:7:in `block in for'
	from ~/dev/truffleruby/bugs/sinatra/config.ru:6:in `tap'
	from ~/dev/truffleruby/bugs/sinatra/config.ru:6:in `for'
@norswap norswap self-assigned this Feb 27, 2020
@norswap
Copy link
Contributor

norswap commented Feb 28, 2020

Minimal reprod:

p __dir__ # ok
def caller_locations
  'override'
end
p __dir__ # nope

@norswap
Copy link
Contributor

norswap commented Feb 28, 2020

Fixed in 1de99bf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants