scope[key] requires that the looked up name is a String - see line 443 in scope.rb (setter) (it throws and exception if an attempt is made to use something other than a String, and so does line 269 (getter).

You can do val = @scope[key.to_s] instead to always lookup with a String.

Oh - I just realized that scope here is not a Puppet::Parser::Scope. Symbols are good because they are fast to compare, but they are not garbage collected, so they should be used with care. Suggest using Strings for both reading and writing. (Your doc says that scope is a Hash<String, String> btw).