Search code examples
crystal-lang

What is superclass mismatch in Crystal Lang?


I am trying to implement a rate-limiting handler with Kemal.

I have a class, RateLimiter, that inherits the class Kemal::Handler. On compile I get the error:

Error in src/rate_limiter.cr:5: superclass mismatch for class RateLimiter (Kemal::Handler for Reference)

I'm new to Crystal and that means nothing to me. What am I doing wrong?


Solution

  • This indicates that RateLimiter was defined previously somewhere, without any explicit superclass specification:

    class Base; end
    class Foo; end
    class Foo < Base; end
    

    That gives

    Error in line 3: superclass mismatch for class Foo (Base for Reference)
    

    https://carc.in/#/r/3r2l

    Search through your project and dependencies for class RateLimiter giving conflicting definitions of that type.