Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile/bind: syntax errors in generated Objective-C code for interface method with 'error' return type #12307

Closed
rod-hynes opened this issue Aug 25, 2015 · 1 comment

Comments

@rod-hynes
Copy link

With gomobile version +979ebce, go 1.5, darwin/amd64 build host, gomobile bind fails for -target ios with the following test package:

package bindtest

import "fmt"

type TestInterface interface {
        TestFunc() error
}

func CallTestFunc(t TestInterface) {
        err := t.TestFunc()
        fmt.Printf("Go library called app's TestFunc and got %s", err)
}

Android target builds successfully: gomobile bind bindtest.

iOS target build fails: gomobile bind -target ios bindtest:

gomobile: darwin-armv7: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -I . -g -O2 -o gobind-bindtest-arm.o -c GoBindtest.m -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk -arch armv7 failed: exit status 1
GoBindtest.m:69:17: error: unexpected interface name 'NSString': expected expression
                                errorDesc = NSString(@"%!@(string=error)", %!s(MISSING));
                                            ^
GoBindtest.m:69:48: error: expected expression
                                errorDesc = NSString(@"%!@(string=error)", %!s(MISSING));
                                                                           ^
GoBindtest.m:69:50: warning: implicit declaration of function 's' is invalid in C99 [-Wimplicit-function-declaration]
                                errorDesc = NSString(@"%!@(string=error)", %!s(MISSING));
                                                                             ^
GoBindtest.m:69:52: error: use of undeclared identifier 'MISSING'
                                errorDesc = NSString(@"%!@(string=error)", %!s(MISSING));
                                                                               ^
GoBindtest.m:71:25: error: expected expression
                go_seq_writeUTF8(out, %!s(MISSING)Desc);
                                      ^
GoBindtest.m:71:29: error: use of undeclared identifier 'MISSING'
                go_seq_writeUTF8(out, %!s(MISSING)Desc);
                                          ^
1 warning and 5 errors generated.

The iOS target works, for the test package, when the return value is changed from error to some other supported type; or when the test package consists of a Go function that returns error. The failing case appears to be an interface method returning error.

The generated code in question appears to come from genobjc.go here and here.

@hyangah hyangah self-assigned this Aug 25, 2015
@gopherbot
Copy link

CL https://golang.org/cl/13913 mentions this issue.

@golang golang locked and limited conversation to collaborators Aug 24, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Fixes golang/go#12307.

Change-Id: I5560b616a3cd51c536d9e5529745681effe26e9a
Reviewed-on: https://go-review.googlesource.com/13913
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Fixes golang/go#12307.

Change-Id: I5560b616a3cd51c536d9e5529745681effe26e9a
Reviewed-on: https://go-review.googlesource.com/13913
Reviewed-by: David Crawshaw <crawshaw@golang.org>
@rsc rsc unassigned hyangah Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants