Skip to content

Implicit super in module_eval/instance_eval with an unrelated self calls the method instead of raising TypeError #136

Closed

Description

@Largo

Implicit-argument super inside a block run with a different self (module_eval, instance_eval, a class body in eval) calls the superclass method anyway. CRuby refuses:

class C; def foo; :c; end; end
class B < C; def foo; [:b, (A.module_eval { super } rescue $!.class)]; end; end
class A; end
p B.new.foo
# CRuby:    [:b, TypeError]   (self has wrong type to call super in this context: Class (expected B))
# IronRuby: [:b, :c]

Likewise super in a class E ... end body inside eval within a method: CRuby says "super called outside of method", IronRuby calls the method's super.

Found by running the scripts PR #119 deleted (Tests/Experiments, Tests/Legacy) on CRuby 4.0.9 and on IronRuby built from master c7f70cf (net10.0, Linux). (Experiments/Super/Scoping2.rb, Scoping4.rb)

Activity

  1. added a commit that references this issue on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions