Skip to content

Instantly share code, notes, and snippets.

@mvidner
Last active June 20, 2016 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvidner/c02b0367a622eddc373774f291a24b83 to your computer and use it in GitHub Desktop.
Save mvidner/c02b0367a622eddc373774f291a24b83 to your computer and use it in GitHub Desktop.
ruby-lint loading definitions of overlapping namespaces
require_relative "project-base"
require_relative "project-ui"
module Project
class Foo
def dialog_exists?
UI.WidgetExists(:dialog)
end
end
end
Project.hello
puts Project::UI.WidgetExists(:button)
puts Project::Foo.new.dialog_exists?
requires:
- ./defs-project
- ./defs-ui-nested
requires:
- ./defs-project
- ./defs-ui-top
# This file was automatically generated, any manual changes will be lost the
# next time this file is generated.
#
# Platform: ruby 2.1.2
puts "loaded #{__FILE__}"
RubyLint.registry.register('Project') do |defs|
puts "registering Project (base)"
defs.define_constant('Project') do |klass|
klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
klass.define_method('hello')
end
end
# This file was automatically generated, any manual changes will be lost the
# next time this file is generated.
#
# Platform: ruby 2.1.2
puts "loaded #{__FILE__}"
RubyLint.registry.register('Project::UI') do |defs|
puts "registering Project::UI"
defs.define_constant('Project::UI') do |klass|
klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
klass.define_method('WidgetExists') do |method|
method.define_rest_argument('args')
end
end
end
# This file was automatically generated, any manual changes will be lost the
# next time this file is generated.
#
# Platform: ruby 2.1.2
puts "loaded #{__FILE__}"
RubyLint.registry.register('Project') do |defs|
puts "registering Project (ui)"
defs.define_constant('Project') do |klass|
klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
end
defs.define_constant('Project::UI') do |klass|
klass.inherits(defs.constant_proxy('Object', RubyLint.registry))
klass.define_method('WidgetExists') do |method|
method.define_rest_argument('args')
end
end
end
module Project
def self.hello
puts "Hello, Project"
end
end
module Project
class UI
def self.WidgetExists(*args)
"#{args.inspect} exists"
end
end
end
#!/bin/sh
ruby app.rb
ruby-lint -c cfg-top.yml app.rb
ruby-lint -c cfg-nested.yml app.rb
exit
# the definitions were made like this
rake -r project-base generate:definitions[Project,.]; mv project.rb defs-project.rb
rake -r project-ui generate:definitions[Project,.]; mv project.rb defs-ui-top.rb
rake -r project-ui generate:definitions[Project::UI,.]; mv project.rb defs-ui-nested.rb
@mvidner
Copy link
Author

mvidner commented Jun 20, 2016

This is issue https://github.com/YorickPeterse/ruby-lint/issues/181

$ ./RUNME.sh 
Hello, Project
[:button] exists
[:dialog] exists
loaded /local/home-mvidner/svn/ruby-lint/mytest/nested-defs/defs-project.rb
loaded /local/home-mvidner/svn/ruby-lint/mytest/nested-defs/defs-ui-top.rb
registering Project (ui)
app.rb: error: line 12, column 1: undefined method hello on Project
loaded /local/home-mvidner/svn/ruby-lint/mytest/nested-defs/defs-project.rb
loaded /local/home-mvidner/svn/ruby-lint/mytest/nested-defs/defs-ui-nested.rb
registering Project (base)
app.rb: error: line 7, column 7: undefined constant UI
app.rb: error: line 13, column 6: undefined constant Project::UI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment