mattn / mruby-require

39 stars 23 forks source link

After mruby #bfd2a539, classes declared in required files are lost #20

Closed pbosetti closed 10 years ago

pbosetti commented 10 years ago

This must have something to do with changes in mrb_load_irep_cxt(), but I can't help in spotting the solution...

mattn commented 10 years ago

I don't reproduce it.

my_build_config.rb (MRUBY_CONFIG=my_build_config.rb)

conf.gem :github => 'mattn/mruby-require', :branch => 'master'
conf.gem :github => 'mattn/mruby-pjson', :branch => 'master'
$ bin/mirb
mirb - Embeddable Interactive Ruby Shell

> PJSON
(mirb):1: uninitialized constant PJSON (NameError)
> require 'mruby-pjson'
 => true
> PJSON
 => PJSON
> PJSON.parse('{}')
 => {}
>
pbosetti commented 10 years ago

That's correct. It works with other mrbgems. But if you create a file

class Test
# whatever here
end

then

$ bin/mirb
> require './test.rb'
 => true
> Test
 (mirb):1: uninitialized constant Test (NameError)
>

I am building the latest mruby master with your mruby-require master on OS X 10.9 with clang, but it also applies on Windows/VS2010. Still had not time enough for testing on Debian, though.

pbosetti commented 10 years ago

I forgot to say: if the test.rb is like that

class Test
# whatever here
end
puts "Hello there!"

you get the nice greetings on stdout. So it must be something related to scoping.

mattn commented 10 years ago

Ah, rb file. Ok, I'll look into it later

mattn commented 10 years ago

@pbosetti Maybe fixed.

pbosetti commented 10 years ago

Til now it seems to work here too. Thanks, @mattn and @matz -P.