cx
cx copied to clipboard
putting commas inside slice indexers (square brackets) gives no error
@corpusc commented on Jul 3
Describe: It apparently ignores everything after the comma, and works as if you just typed the 1st (leftmost) number.
To Reproduce Steps to reproduce the behavior:
- Try this:
package main
type Shape struct { Cells [][][][]bool }
var Curr Shape
func main() { Curr.Cells[0] = append(Curr.Cells[0], true) Curr.Cells[0,0] = append(Curr.Cells[0,0], true) Curr.Cells[0,0] = append(Curr.Cells[0,0], true) Curr.Cells[0,0,0] = append(Curr.Cells[0,0,0], true) Curr.Cells[0,0,0] = append(Curr.Cells[0,0,0], true) Curr.Cells[0,0,0] = append(Curr.Cells[0,0,0], true) i32.print(len(Curr.Cells[0])) i32.print(len(Curr.Cells[0,0])) i32.print(len(Curr.Cells[0,0,0])) }
Expected behavior An error message to let you know indexing doesn't work this way in CX (I believe it DOES in some other languages)
Desktop:
- OS: Windows 10
- CX Version 0.7.0 full release
This code now gives following error:
error: test1.cx:10, CX_RUNTIME_SLICE_INDEX_OUT_OF_RANGE, 9
===Callstack===
>>> main()
panic: 9 [recovered]
panic: 9
goroutine 1 [running, locked to thread]:
github.com/skycoin/cx/cx.CalculateDereferences(0xc0006583c0, 0xc000626cd0, 0x0)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/fix_mem2.go:61 +0x3d8
github.com/skycoin/cx/cx.GetFinalOffset(0x0, 0xc0006583c0, 0xc0002cc197)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/fix_mem3.go:40 +0x6f
github.com/skycoin/cx/cx.ReadBool(0x0, 0xc0006583c0, 0x7ff758467e7c)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/fix_read3.go:182 +0x45
github.com/skycoin/cx/cx.getNonCollectionValue(0x0, 0xc000658280, 0xc0006583c0, 0x7ff758467ccc, 0x4, 0xc0002cc194, 0x4)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/utilities.go:913 +0x5d5
github.com/skycoin/cx/cx.GetPrintableValue(0x0, 0xc000658280, 0x17f, 0xc00029b938)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/utilities.go:1005 +0x21c
github.com/skycoin/cx/cx.(*CXProgram).PrintStack(0xc0001a60f0)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/utilities.go:88 +0xb05
github.com/skycoin/cx/cx.runtimeErrorInfo(0x7ff7583d6400, 0x7ff75851f250, 0x7ff75851f201, 0x5)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/utilities.go:878 +0x30b
github.com/skycoin/cx/cx.RuntimeError()
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/utilities.go:905 +0x185
panic(0x7ff7583d6400, 0x7ff75851f250)
C:/Program Files/Go/src/runtime/panic.go:965 +0x1c7
github.com/skycoin/cx/cx.CalculateDereferences(0xc0006583c0, 0xc0006275a8, 0x0)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/fix_mem2.go:61 +0x3d8
github.com/skycoin/cx/cx.GetFinalOffset(0x0, 0xc000658280, 0x7ff757e0acf4)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/fix_mem3.go:44 +0xc5
github.com/skycoin/cx/cx.GetSliceOffset(0x0, 0xc000658280, 0x0)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/utilities.go:630 +0x65
github.com/skycoin/cx/cx.opAppend(0xc0000d6630, 0x0)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/op_und.go:527 +0xf6
github.com/skycoin/cx/cx.(*CXCall).ccall(0xc000120000, 0xc0001a60f0, 0x100000002, 0x0)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/execute.go:330 +0x16e9
github.com/skycoin/cx/cx.(*CXProgram).Run(0xc0001a60f0, 0x7ff758467701, 0xc000627bd0, 0xffffffffffffffff, 0x0, 0x0)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/execute.go:119 +0x2f2
github.com/skycoin/cx/cx.(*CXProgram).RunCompiled(0xc0001a60f0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7ff75849f098)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cx/execute.go:238 +0x31f
main.runProgram(0x0, 0x7ff75851f248, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cmd/cx/main.go:225 +0x125
main.Run(0xc0000523d0, 0x1, 0x1)
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cmd/cx/main.go:110 +0x528
main.main()
C:/Users/tursi/OneDrive/Desktop/go-workspace/src/Projects/cx/cmd/cx/main.go:24 +0x6f