[gollvm/gofrontend]unnamed bool convert error

110 views
Skip to first unread message

hang gao

unread,
Apr 19, 2022, 12:28:08 AM4/19/22
to golang-nuts
Hi,
I got a assert fail for gollvm when compiling test/fixedbugs/issue16870.go

the assert is in function names.cc / Gogo::type_descriptor_backend_name

It is caused by the example like this.

when there is a channel/map/... used with an empty interface like this:

func test(got, want interface{})

var ok interface{}

m:=make(map[int]int)

i, ok = m[0]

test(ok,false)

If we receive the bool value from the  i, ok = m[0] and convert it to an empty interface, the assert will be triggered

I found that the return value of functions like mapaccess2 are generated as unnamed types, which means they use make_boolean_type() rather than make_named_bool_type(),  is this reasonable? and do you know how to fix it?

Thanks!

hang gao

unread,
Apr 25, 2022, 12:17:17 AM4/25/22
to golang-nuts
I found that when receiving the ret val from functions,the RFT_BOOL will use Type::make_boolean_type() which will generate a unnamed bool type,
I would like to change this to Type::lookup_bool_type();
I just wondering if this is ok ?

The code is in gofrontend/go/runtime.cc/runtime_function_type

Ian Lance Taylor

unread,
Jun 23, 2022, 8:34:15 PM6/23/22
to hang gao, golang-nuts
For the record, this became https://go.dev/issue/52535, q.v.

Thanks for the report.

Ian
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8639f65f-248f-455c-99ec-3ddf8a2eeb14n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages