Skip to content

Null ptr error in -[NSAppleScript executeAndReturnError:] #803

@lhz07

Description

@lhz07

found an issue in the generated binding for -[NSAppleScript executeAndReturnError:].

The current Rust signature is:

/// # Safety
///
/// `error_info` generic should be of the correct type.
#[unsafe(method(executeAndReturnError:))]
#[unsafe(method_family = none)]
pub unsafe fn executeAndReturnError(
    &self,
    error_info: Option<&mut Option<Retained<NSDictionary<NSString, AnyObject>>>>,
) -> Retained<NSAppleEventDescriptor>;

However, according to Apple’s documentation, the Objective-C method is:

- (NSAppleEventDescriptor *)executeAndReturnError:(NSDictionary<NSString *, id> **)errorInfo;
// Return Value: The result of executing the event, or nil if an error occurs.

The return value is nullable. But the generated Rust binding uses Retained<NSAppleEventDescriptor> instead of an Option<Retained<…>>. As a result, when the AppleScript execution fails, the Rust code panics:

thread '<unnamed>' panicked at .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/objc2-foundation-0.3.2/src/generated/NSAppleScript.rs:60:5:
unexpected NULL returned from -[NSAppleScript executeAndReturnError:]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-frameworkAffects the framework crates and the translator for thembugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions