Skip to content

Support for reflect package in TinyGo #2660

@srikarrao

Description

@srikarrao

Is the reflect package implemented in the latest version of Tinygo? I'm trying to decode the JSON in Go WASM and I have been getting the below error that reflect.Type.NumMethod() is unimplemented. I found a couple of issues reported earlier, I'm not sure if this is implemented. However, the TinyGo's supported libs document says it does allow importing encoding/json package.

Previous Issues:
#907
#575

Versions used:

> go version 
	go1.17.6 darwin/amd64
> tinygo version
	tinygo version 0.22.0 darwin/amd64 (using go version go1.17.6 and LLVM version 13.0.0)
> proxy-wasm-go-sdk version
	github.com/tetratelabs/proxy-wasm-go-sdk v0.16.0

Error logs:

proxy_1        | [2022-03-02 02:08:03.668][1][info][wasm] [source/extensions/common/wasm/context.cc:1170] wasm log: panic: unimplemented: (reflect.Type).NumMethod()
proxy_1        | [2022-03-02 02:08:03.668][1][error][wasm] [source/extensions/common/wasm/wasm_vm.cc:38] Function: proxy_on_tick failed: Uncaught RuntimeError: unreachable
proxy_1        | Proxy-Wasm plugin in-VM backtrace:
proxy_1        |   0:  0x170f - runtime._panic
proxy_1        |   1:  0x326d - (reflect.rawType).NumMethod
proxy_1        |   2:  0x6c23a - (*gopkg.in/square/go-jose.v2/json.decodeState).indirect
proxy_1        |   3:  0x696e5 - (*gopkg.in/square/go-jose.v2/json.decodeState).object
proxy_1        |   4:  0x687dc - (*gopkg.in/square/go-jose.v2/json.decodeState).value
proxy_1        |   5:  0x2af8b - gopkg.in/square/go-jose.v2/json.Unmarshal
proxy_1        |   6:  0x65be4 - (*gopkg.in/square/go-jose.v2.JSONWebKey).UnmarshalJSON
proxy_1        |   7:  0x64cef - proxy_on_tick

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already existsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions