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: Cryptic error message when a keyword that is reserved in C/ObjC but not in Golang is used in Go code #16560

Closed
petejkim opened this issue Aug 1, 2016 · 2 comments

Comments

Projects
None yet
5 participants
@petejkim
Copy link

commented Aug 1, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

    1.6.3
    
  2. What operating system and processor architecture are you using (go env)?

    darwin/amd64
    
  3. What did you do?

    $GOPATH/src/github.com/petejkim/foo/foo.go

    package foo
    
    func DoSomethingWithLocation(lat, long, alt float64) float64 {
      return 0.0
    }
    
    $ gomobile bind -target=ios github.com/petejkim/foo
    gomobile: darwin-armv7: go build -p=8 -pkgdir=/Users/jihoon/code/go/pkg/gomobile/pkg_darwin_arm -tags="" -buildmode=c-archive -tags=ios -o /var/folders/7t/zvcfl61j57d722hzvyxm5cym0000gn/T/gomobile-work-326555581/foo-arm.a /var/folders/7t/zvcfl61j57d722hzvyxm5cym0000gn/T/gomobile-work-326555581/src/iosbin/main.go failed: exit status 2
    # _/var/folders/7t/zvcfl61j57d722hzvyxm5cym0000gn/T/gomobile-work-326555581/src/gomobile_bind
    /var/folders/7t/zvcfl61j57d722hzvyxm5cym0000gn/T/gomobile-work-326555581/src/gomobile_bind/GoFoo.m:21:54: error: parameter name omitted
    /var/folders/7t/zvcfl61j57d722hzvyxm5cym0000gn/T/gomobile-work-326555581/src/gomobile_bind/GoFoo.m:23:25: error: expected expression
    
  4. What did you expect to see?

    I expected it to show an error saying it cannot be compiled due to the presence of reserved keyword long. It would be better if it could just handle it automatically by perhaps prepending/appending _ to the reserved keyword (_long) to avoid Obj-C compilation error.

  5. What did you see instead?

    A cryptic error message. It took me a while before I realized it was due to the argument name long (short for longitude in my case), which is a reserved keyword (a data type) in ObjC.

@quentinmit quentinmit added this to the Unreleased milestone Aug 1, 2016

@8tt

This comment has been minimized.

Copy link

commented Sep 12, 2016

Another example:

package bug
type Interface1 interface {
}
func Func1(i Interface1, id int) int {
  return 0
}


gomobile: darwin-armv7: go build -pkgdir=/Users/go/pkg/gomobile/pkg_darwin_arm -tags="" -buildmode=c-archive -tags=ios -o /var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/bug-arm.a /var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/iosbin/main.go failed: exit status 2
# _/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind
/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind/GoBug.m:28:11: error: unexpected interface name 'NSObject': expected expression
/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind/GoBug.m:28:20: error: expected expression
/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind/GoBug.m:29:6: error: use of undeclared identifier 'goSeqRefInterface'
/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind/GoBug.m:29:25: error: use of undeclared identifier 'i_proxy'
/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind/GoBug.m:29:39: error: use of undeclared identifier 'goSeqRefInterface'
/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind/GoBug.m:29:57: error: expected expression
/var/folders/0t/psgmc08n0zl8t_6p341krqqw0000gn/T/gomobile-work-375998048/src/gomobile_bind/GoBug.m:30:28: error: use of undeclared identifier 'i_proxy'

@gopherbot gopherbot added the mobile label Jul 20, 2017

@eliasnaur

This comment has been minimized.

Copy link
Contributor

commented Mar 16, 2018

@eliasnaur eliasnaur closed this Mar 16, 2018

@golang golang locked and limited conversation to collaborators Mar 16, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.