Skip to content

CLR string: an undefined bang method raises TypeError "Mutating method" instead of NoMethodError #159

Closed

Description

@Largo

Left over from #141 (neither #148 nor #155 changed it).

A System::String turns any method name ending in ! into a "Mutating method" TypeError, even when no such method exists:

"a".to_clr_string.foo!      # => TypeError: Mutating method 'foo!' called for an immutable string (System::String)
"a".to_clr_string.upcase!   # => TypeError: Mutating method 'upcase!' called for an immutable string (System::String)

An undefined method should be a NoMethodError, as CRuby raises for a String ("a".foo! gives NoMethodError: undefined method 'foo!' for an instance of String). The TypeError fits only a bang method that String actually defines (upcase!, gsub!, ...), because a CLR string cannot be changed in place.

Checked on master + #155, Linux net10.0.

🤖 Generated with Claude Code

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