Skip to content

ObjC selector with $ panics ("take$foo" is not a valid Ident) #3483

Description

@lwz23

Input C/C++ Header

__attribute__((objc_root_class))
@interface Foo
- (int)take$foo:(int)t;
@end

Bindgen Invocation

$ bindgen input.h -- -x objective-c

Actual Results

bindgen aborts:

panicked at bindgen/ir/objc.rs:264:30:
"take$foo" is not a valid Ident

clang accepts $ in the selector. C names with $ already go through rust_mangle ($_). ObjC format_method_call passes selector fragments to Ident::new / syn::parse_str without that.

This is not #2486 (keyword type / self) or #1703 (empty :: fragments).

Expected Results

Do not abort. Mangle $ in selector fragments the same way C identifiers are mangled.

Environment

bindgen: 0.73.1 (rust-lang/rust-bindgen 77cbc723)
clang/libclang: Homebrew clang 21.1.8
rustc: 1.97.1
target: aarch64-apple-darwin
OS: macOS

Activity

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