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

Module.instance_eval not working #5528

Closed
sasq64 opened this issue Aug 11, 2021 · 5 comments
Closed

Module.instance_eval not working #5528

sasq64 opened this issue Aug 11, 2021 · 5 comments

Comments

@sasq64
Copy link
Contributor

sasq64 commented Aug 11, 2021

The following code fails with
uninitialized constant #<Class:0x68fa70>::A (NameError)

     m = Module.new
     m.instance_eval("
     class A end
     class B
         def initialize()
             p A
         end
     end
     B.new
")
@sasq64
Copy link
Contributor Author

sasq64 commented Aug 11, 2021

Also, after you get this error, plain eval() also breaks for the same code...

@sasq64
Copy link
Contributor Author

sasq64 commented Aug 11, 2021

Shorter repro:

 Module.new.class_eval("
 class A end
 class B
     p A
 end
") 

@matz
Copy link
Member

matz commented Aug 12, 2021

It's caused by #5497. Shall I revert it @dearblue?

@matz
Copy link
Member

matz commented Aug 12, 2021

#5497 reverted. @dearblue please retry.

@dearblue
Copy link
Contributor

@sasq64 Thank you for reporting the issue.
@matz Thank you for revert #5497. If done well, I'll PR again.

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

3 participants