Open xiaxinmeng opened 1 year ago
In gpython, if we define a nested set, it will lead to crashing. s = {('string', 1), ('string', 2), ('string', 3)}
s = {('string', 1), ('string', 2), ('string', 3)}
Output on go/wasm(https://gpython.org/?wasm):
Gpython 3.4.0 running in your browser with go/wasm >>> s = {('string', 1), ('string', 2), ('string', 3)} panic: runtime error: hash of unhashable type py.Tuple goroutine 5 [running]: github.com/go-python/gpython/py.NewSetFromItems(0xc09a880, 0x3, 0x4, 0x2) /home/ncw/go/src/github.com/go-python/gpython/py/set.go:42 +0xc github.com/go-python/gpython/vm.do_BUILD_SET(0xc074770, 0x3, 0x0, 0x0) /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:996 +0x5 github.com/go-python/gpython/vm.RunFrame(0xc0de0b0, 0x0, 0xc07bd18, 0x0, 0x0) /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:1785 +0x3f github.com/go-python/gpython/vm.EvalCodeEx(0xc04c200, 0xc062db0, 0xc062db0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:2162 +0xa3 github.com/go-python/gpython/vm.Run(0xc062db0, 0xc062db0, 0xc04c200, 0x0, 0x0, 0x0, 0x0, 0x1, 0x9d240, 0xc04c200) /home/ncw/go/src/github.com/go-python/gpython/vm/eval.go:2182 +0x2 github.com/go-python/gpython/repl.(*REPL).Run(0xc09a6c0, 0xc09c080, 0x31) /home/ncw/go/src/github.com/go-python/gpython/repl/repl.go:99 +0x20 main.main.func1(0xc01e3f0, 0x2, 0x2) /home/ncw/go/src/github.com/go-python/gpython/repl/web/main.go:82 +0x4 syscall/js.callbackLoop() /opt/go/go1.11/src/syscall/js/callback.go:116 +0x7 created by syscall/js.NewCallback.func1 /opt/go/go1.11/src/syscall/js/callback.go:40 +0x2
output with gopherjs(https://gpython.org/):
Gpython 3.4.0 running in your browser with gopherjs >>> s = {('string', 1), ('string', 2), ('string', 3)} [USER]: https://gpython.org/gpython.js: n.keyFor is not a function $ifaceKeyFor@https://gpython.org/gpython.js:4:9630 LL@https://gpython.org/gpython.js:41:324569 BY@https://gpython.org/gpython.js:44:56407 DO@https://gpython.org/gpython.js:44:91592 DU@https://gpython.org/gpython.js:44:107450 DW@https://gpython.org/gpython.js:44:109015 G.ptr.prototype.Run@https://gpython.org/gpython.js:56:3575 $b@https://gpython.org/gpython.js:60:3908 $b@https://gpython.org/gpython.js:59:2625 r@https://gpython.org/gpython.js:4:23443 $runScheduled@https://gpython.org/gpython.js:4:24007 $schedule@https://gpython.org/gpython.js:4:24184 $go@https://gpython.org/gpython.js:4:23907 I/$packages["github.com/gopherjs/gopherwasm/js"]<@https://gpython.org/gpython.js:59:2240 $externalizeFunction/e.$externalizeWrapper@https://gpython.org/gpython.js:4:28925 a@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:82615 k@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:83463 ENTER@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:14915 $e@https://cdnjs.cloudflare.com/ajax/libs/jquery.terminal/1.23.2/js/jquery.terminal.min.js:40:28362 dispatch@https://code.jquery.com/jquery-latest.js:4641:9 add/elemData.handle@https://code.jquery.com/jquery-latest.js:4309:28
I can confirm this problem.
In gpython, if we define a nested set, it will lead to crashing.
s = {('string', 1), ('string', 2), ('string', 3)}
Output on go/wasm(https://gpython.org/?wasm):
output with gopherjs(https://gpython.org/):