Open p-offtermatt opened 10 months ago
I am having issues with maps where the keys are not easily converted to strings.
I have uploaded a PR with two example test cases.
TestUnmarshallRecordAsMapKey fails parsing with this error:
--- FAIL: TestUnmarshallRecordAsMapKey (0.00s) panic: interface conversion: interface {} is []interface {}, not string [recovered] panic: interface conversion: interface {} is []interface {}, not string goroutine 21 [running]: testing.tRunner.func1.2({0x102f9aa80, 0x140000a4ff0}) /opt/homebrew/Cellar/go/1.21.3/libexec/src/testing/testing.go:1545 +0x1c8 testing.tRunner.func1() /opt/homebrew/Cellar/go/1.21.3/libexec/src/testing/testing.go:1548 +0x360 panic({0x102f9aa80?, 0x140000a4ff0?}) /opt/homebrew/Cellar/go/1.21.3/libexec/src/runtime/panic.go:914 +0x218 github.com/informalsystems/itf-go/itf.toString({0x102f8ac00?, 0x140000ac1e0?}) /Users/offtermatt/projects/itf-go/itf/trace.go:171 +0x118 github.com/informalsystems/itf-go/itf.mapToString[...](0x140000a4f00) /Users/offtermatt/projects/itf-go/itf/trace.go:184 +0x1c0 github.com/informalsystems/itf-go/itf.toString({0x102f97860?, 0x140000a4f00?}) /Users/offtermatt/projects/itf-go/itf/trace.go:169 +0x8c github.com/informalsystems/itf-go/itf.mapToString[...](0x140000a4ed0) /Users/offtermatt/projects/itf-go/itf/trace.go:184 +0x1c0 github.com/informalsystems/itf-go/itf.toString({0x102f97860?, 0x140000a4ed0?}) /Users/offtermatt/projects/itf-go/itf/trace.go:169 +0x8c github.com/informalsystems/itf-go/itf.toExpr({0x102f97860?, 0x140000a4ea0?}) /Users/offtermatt/projects/itf-go/itf/trace.go:101 +0x784 github.com/informalsystems/itf-go/itf.toExpr({0x102f97860?, 0x140000a4e70?}) /Users/offtermatt/projects/itf-go/itf/trace.go:147 +0x428 github.com/informalsystems/itf-go/itf.(*Expr).UnmarshalJSON(0x14000090520, {0x14000118002, 0x118, 0x118}) /Users/offtermatt/projects/itf-go/itf/trace.go:199 +0xb8 encoding/json.(*decodeState).object(0x1400011a000, {0x102f94da0?, 0x14000090520?, 0x102e7b9dc?}) /opt/homebrew/Cellar/go/1.21.3/libexec/src/encoding/json/decode.go:604 +0x5d4 encoding/json.(*decodeState).value(0x1400011a000, {0x102f94da0?, 0x14000090520?, 0x102e7afc4?}) /opt/homebrew/Cellar/go/1.21.3/libexec/src/encoding/json/decode.go:374 +0x40 encoding/json.(*decodeState).unmarshal(0x1400011a000, {0x102f94da0?, 0x14000090520?}) /opt/homebrew/Cellar/go/1.21.3/libexec/src/encoding/json/decode.go:181 +0x120 encoding/json.Unmarshal({0x14000118000, 0x11a, 0x11a}, {0x102f94da0, 0x14000090520}) /opt/homebrew/Cellar/go/1.21.3/libexec/src/encoding/json/decode.go:108 +0xf8 github.com/informalsystems/itf-go/itf.TestUnmarshallRecordAsMapKey(0x0?) /Users/offtermatt/projects/itf-go/itf/trace_test.go:160 +0x90 testing.tRunner(0x14000083520, 0x102fcc678) /opt/homebrew/Cellar/go/1.21.3/libexec/src/testing/testing.go:1595 +0xe8 created by testing.(*T).Run in goroutine 1 /opt/homebrew/Cellar/go/1.21.3/libexec/src/testing/testing.go:1648 +0x33c
TestUnmarshallRecordWithIntsAsMapKey is a test case that highlights that the map keys should not always be strings, in this case the key of the map item is the string "a#bigint1b#bigint2"
This is the PR: https://github.com/informalsystems/itf-go/pull/3
I am having issues with maps where the keys are not easily converted to strings.
I have uploaded a PR with two example test cases.
TestUnmarshallRecordAsMapKey fails parsing with this error:
TestUnmarshallRecordWithIntsAsMapKey is a test case that highlights that the map keys should not always be strings, in this case the key of the map item is the string "a#bigint1b#bigint2"