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

[Truffle] module_eval missing constant error #3052

Closed
bjfish opened this issue Jun 15, 2015 · 4 comments
Closed

[Truffle] module_eval missing constant error #3052

bjfish opened this issue Jun 15, 2015 · 4 comments
Assignees
Milestone

Comments

@bjfish
Copy link
Contributor

bjfish commented Jun 15, 2015

Found in RSS lib,
Example

module ExampleModule
   class Element
   end

   module_eval(<<-HEREDOC
   class Test < Element
      def hello
        puts "Hello"
      end
   end
   HEREDOC
   )
end
ExampleModule::Test.new.hello

Expected

$ ruby modeval.rb 
Hello

Actual

$ ~/Documents/jruby/bin/jruby -X+T modeval.rb 
(eval):2:in `const_missing': uninitialized constant Element (NameError)
    from (eval):2:in `<main>'
    from modeval.rb:5:in `ExampleModule'
    from modeval.rb:1:in `<main>'
@eregon
Copy link
Member

eregon commented Jun 16, 2015

I guess we should preserve lexical scope across eval.

@chrisseaton
Copy link
Contributor

Simpler test case:

module ExampleModule
   FOO = 14
   p module_eval("FOO")
end

@eregon eregon self-assigned this Jun 17, 2015
@eregon eregon closed this as completed in 1386a17 Jun 17, 2015
@eregon
Copy link
Member

eregon commented Jun 17, 2015

Fixed.

@chrisseaton chrisseaton added this to the truffle-dev milestone Jun 17, 2015
@chrisseaton
Copy link
Contributor

Please add truffle-dev to any closed PRs or issues.

@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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

4 participants