-
-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Description
Hello @fxn 👋 ,
Thanks a lot for Zeitwerk, it's a really cool gem.
I'm opening this issue to check if this is something Zeitwerk should support or our application is just not compliant with the file structure described by the Gem.
We have multiple files that have multiple classes inside, it's especially common for grouping error class inside a single file instead of having a bunch of files.
# application_error.rb
class ApplicationError < StandardError
end
class CustomError < ApplicationError
endZeitwerk has issues with reloading this and ruby will throw a TypeError: superclass mismatch for class CustomError. This make sense since CustomError was never marked for autoloading.
Here is a failing test
index dd69b8b..372ab87 100644
--- a/test/lib/zeitwerk/test_reloading.rb
+++ b/test/lib/zeitwerk/test_reloading.rb
@@ -18,6 +18,21 @@ class TestReloading < LoaderTest
assert loader.reloading_enabled?
end
+ test "superclass mismatch error" do
+ files = [
+ ["x.rb", "class X; end; class AnotherX < X; end"]
+ ]
+
+ with_setup(files) do
+ assert X
+ assert AnotherX
+
+ loader.reload
+
+ assert X
+ end
+ end
+
test "reloading works if the flag is set" do
files = [
["x.rb", "X = 1"], # top-levelHappy to work on finding a fix if you consider that Zeitwerk should handle this case. Thanks!
Metadata
Metadata
Assignees
Labels
No labels