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

Top-level def should not wind up in Shoes::App #487

Open
noahgibbs opened this issue Dec 9, 2023 · 1 comment
Open

Top-level def should not wind up in Shoes::App #487

noahgibbs opened this issue Dec 9, 2023 · 1 comment

Comments

@noahgibbs
Copy link
Collaborator

Oops!

def not_in_shoes_app
  STDERR.puts "Self: #{self.inspect}"
  button "Oops! Doesn't work"
end

Shoes.app do
  background blue

  not_in_shoes_app
end

This shouldn't work. The method should be defined on Ruby's main object, not on Shoes.app. It's happening because we eval the block inside the Shoes app instance, which is wrong.

@noahgibbs
Copy link
Collaborator Author

Huh. Okay, so the top level stuff is not defined on Shoes::App. But a top-level method, which can be called from anywhere (like how stuff in Kernel works) will cheerfully be called with whatever the old self variable was. So this isn't a Shoes or Scarpe bug, though you could maybe make the case that it's a Ruby bug.

I need to investigate Shoes3 TOPLEVEL_BINDING stuff (that's a Ruby constant, but Shoes uses it in several places for evals.) I'm not sure if that would fix this problem, or if it would do exactly what our current use of "load" does.

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

No branches or pull requests

1 participant