rdoc/rdoc — Issue #105: Context#modules and #classes error
Author: trans
Created: 2012-03-07 18:50:41+00:00
State: open

```
>> gem 'rdoc', '>3'
>> require 'rdoc'
>> ri = ::RDoc::RI::Store.new('.rdoc')
=> #
>> ri.load_cache
=> {:ancestors=>{"FishSampler::Fish"=>["Object"], "FishSampler::RedFish"=>["Object"], "FishSampler::BlueFish"=>["FishSampler::Fish"], "FishSampler::OldFish"=>["FishSampler::Fish"], "FishSampler::NewFish"=>["FishSampler::Fish"], "FishSampler::Shark"=>["FishSampler::Fish", "FishSampler::ManEater"], "Numeric"=>["Numeric::Multipliers", "Object"]}, :attributes=>{"FishSampler::Fish"=>["attr_accessor properties", "attr_accessor qualities"], "FishSampler::RedFish"=>["attr_accessor qualities"], "FishSampler::BlueFish"=>["attr_accessor qualities"], "FishSampler::OldFish"=>["attr_accessor qualities"], "FishSampler::NewFish"=>["attr_accessor qualities"], "FishSampler"=>["attr_reader fishy_active"]}, :class_methods=>{"FishSampler::Fish"=>["new"], "FishSampler"=>["fishy_active"]}, :encoding=>#, :instance_methods=>{"FishSampler::Fish"=>["initialize_qualities", "properties", "qualities"], "FishSampler::RedFish"=>["initialize_qualities", "qualities"], "FishSampler::BlueFish"=>["initialize_qualities", "qualities"], "FishSampler::OldFish"=>["initialize_qualities", "qualities"], "FishSampler::NewFish"=>["initialize_qualities", "qualities"], "FishSampler::Shark"=>["initialize_qualities"], "FishSampler::ManEater"=>["initialize_qualities"], "Numeric::Multipliers"=>["atto", "centi", "deci", "deka", "exa", "exbi", "femto", "gibi", "giga", "hecto", "kibi", "kilo", "mebi", "mega", "micro", "milli", "nano", "pebi", "peta", "pico", "tebi", "tera"]}, :modules=>["FishSampler", "FishSampler::BlueFish", "FishSampler::Fish", "FishSampler::ManEater", "FishSampler::NewFish", "FishSampler::OldFish", "FishSampler::RedFish", "FishSampler::Shark", "Numeric", "Numeric::Multipliers"]}
>> k = ri.load_class(ri.modules.first)
=> #] methods: [] aliases: []>
>> k.modules
NoMethodError: undefined method `values' for nil:NilClass
from /home/trans/.rbfu/rubies/1.9.3-p0/lib/ruby/gems/gems/rdoc-3.12/lib/rdoc/context.rb:936:in `modules'
from (irb):7
from /home/trans/.rbfu/rubies/1.9.3-p0/bin/irb:12:in `

'
```

Since there are no modules in this case, I would expect it to return an empty array (preferably). But since there are none, the `@classes` attribute in `RDoc::Context` is `nil` instead of a Hash, so when `#values` is called against it, this error occurs.