Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[BridgeJS] Compilation error when struct doesn’t have in-order initialiser #718

Copy link
Copy link
@wfltaylor

Description

@wfltaylor
Issue body actions

If a @JS struct doesn’t have an initialiser that accepts all of its fields in-order (with the names matching exactly), the generated code fails to compile. In other words, the struct must have an initialiser that matches the signature of the generated memberwise one.

For example, this struct generates code that fails to compile:

@JS public struct Animal {

    public var size: Size
    public var age: Age

    @JS public init(age: Age, size: Size) {
        self.age = age
        self.size = size
    }

}
extension Animal: _BridgedSwiftStruct {
    @_spi(BridgeJS) @_transparent public static func bridgeJSStackPop() -> Animal {
        let size = Size.bridgeJSStackPop()
        let age = Age.bridgeJSStackPop()
        return Animal(size: size, age: age) // error: argument 'age' must precede argument 'size'
    }

Possible solutions include diagnosing this more clearly, or maybe the @JS macro could generate its own @_spi(BridgeJS) initialiser?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.