Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: primitive type int cannot be indexed #2660

Closed
piux2 opened this issue Aug 5, 2024 · 2 comments
Closed

error: primitive type int cannot be indexed #2660

piux2 opened this issue Aug 5, 2024 · 2 comments
Assignees
Labels
🐞 bug Something isn't working

Comments

@piux2
Copy link
Contributor

piux2 commented Aug 5, 2024

Description

Problem: file test failed with panic: primitive type int cannot be indexed

package main

func Inc()int  {
	a := [1]int{0}
	defer func() {
		a[0]++
	}()
	return a[0]
}

func main(){
	i := Inc()
	println(i)
}

// Output:
// 0

Trace:

Machine.RunMain() panic: primitive type int cannot be indexed
Machine:
    CheckTypes: false
    Op: [OpHalt OpPopResults OpExec OpBody OpDefine OpBody OpReturnFromBlock OpReturnCallDefers OpBody]
    Values: (len: 2)
          #1 (Inc func()( int))
          #0 (main func()())
    Exprs:
    Stmts:
          #3 bodyStmt[0/0/1]=(end)
          #2 bodyStmt[0/0/3]=(end)
          #1 bodyStmt[0/0/1]=(const (println func(xs ...interface{})()))(i<VPBlock(1,0)>)*
          #0 return
    Blocks:
          @(145) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003fcd20,Source:func func(){ a<VPBlock(2,0)>[(co...,Parent:0x140003fcb40)
 (s vals) @(145) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x14000362e30,Source:func func(){ a<VPBlock(2,0)>[(co...,Parent:0x140003bb430)
 (s typs) @(145) []
          @(253) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003fcb40,Source:func Inc()  (const-type int) { a...,Parent:0x140003fc5a0)
            a: (0 int)
            .res_0: (undefined)
 (s vals) @(253) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003bb430,Source:func Inc()  (const-type int) { a...,Parent:0x140003e0630)
            a: (nil [1]int)
            .res_0: (0 int)
 (s typs) @(253) [[1]int int]
          @(402) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003fc5a0,Source:file{ package main; func Inc()  ...,Parent:0x140003425a0)
 (s vals) @(402) Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003e0630,Source:file{ package main; func Inc()  ...,Parent:0x140001a3b30)
 (s typs) @(402) []
          @(511) main
    Blocks (other):
          #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003fcb40,Source:func Inc()  (const-type int) { a...,Parent:0x140003fc5a0)
            a: (0 int)
            .res_0: (undefined)
 (static) #2 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003bb430,Source:func Inc()  (const-type int) { a...,Parent:0x140003e0630)
            a: (nil [1]int)
            .res_0: (0 int)
          #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003fc960,Source:func main() { i<VPBlock(1,0)> :=...,Parent:0x140003fc5a0)
            i: (undefined)
 (static) #1 Block(ID:0000000000000000000000000000000000000000:0,Addr:0x140003bb830,Source:func main() { i<VPBlock(1,0)> :=...,Parent:0x140003e0630)
            i: (0 int)
    Frames:
          #1 [FRAME FUNC:Inc RECV:(undefined) (0 args) 5/1/0/2/2 LASTPKG:main LASTRLM:Realm(nil)]
          #0 [FRAME FUNC:main RECV:(undefined) (0 args) 2/0/0/0/1 LASTPKG:main LASTRLM:Realm(nil)]
    Exceptions:

OUTPUT:

ERROR:
primitive type int cannot be indexed
goroutine 36 [running]:
runtime/debug.Stack()
	/Users/b/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/debug/stack.go:24 +0x64
runtime/debug.PrintStack()
	/Users/b/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/debug/stack.go:16 +0x1c
github.com/gnolang/gno/gnovm/tests.RunFileTest.func1.1()
	/Users/b/dev/gnoplay/gno/gnovm/tests/file.go:153 +0x1e0
panic({0x1052bc860?, 0x140003fe040?})
	/Users/b/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/panic.go:770 +0x124
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunMain.func1()
	/Users/b/dev/gnoplay/gno/gnovm/pkg/gnolang/machine.go:752 +0xb0
panic({0x1052bc860?, 0x140003fe040?})
	/Users/b/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.4.darwin-arm64/src/runtime/panic.go:770 +0x124
github.com/gnolang/gno/gnovm/pkg/gnolang.(*TypedValue).GetPointerAtIndex(0x14000392050, 0x140003fcb40?, {0x1053bd3f0, 0x1400033e8c0}, 0x14000392078)
	/Users/b/dev/gnoplay/gno/gnovm/pkg/gnolang/values.go:2029 +0xa88
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).PopAsPointer(0x1?, {0x1053b3d80?, 0x140003ad540?})
	/Users/b/dev/gnoplay/gno/gnovm/pkg/gnolang/machine.go:2032 +0x168
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).doOpInc(0x14000364b48)
	/Users/b/dev/gnoplay/gno/gnovm/pkg/gnolang/op_inc_dec.go:14 +0xc4
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).Run(0x14000364b48)
	/Users/b/dev/gnoplay/gno/gnovm/pkg/gnolang/machine.go:1486 +0xa6c
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunStatement(0x14000364b48, {0x1053b4c80, 0x140003c4700})
	/Users/b/dev/gnoplay/gno/gnovm/pkg/gnolang/machine.go:864 +0x330
github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunMain(0x14000364b48)
	/Users/b/dev/gnoplay/gno/gnovm/pkg/gnolang/machine.go:755 +0x154
github.com/gnolang/gno/gnovm/tests.RunFileTest.func1(0x7?, 0x1053a6aa8?, {0x0?, 0x0?}, 0x140001a0c18, {0x1050a31d5, 0x4}, {0x1050a31d5, 0x4}, {0x1053bd3f0, ...}, ...)
	/Users/b/dev/gnoplay/gno/gnovm/tests/file.go:176 +0x7e0
github.com/gnolang/gno/gnovm/tests.RunFileTest({0x1400036fc98, 0x5}, {0x1400036fc70, 0xd}, {0x140003611e0, 0x3, 0x4?})
	/Users/b/dev/gnoplay/gno/gnovm/tests/file.go:245 +0x218
github.com/gnolang/gno/gnovm/tests.runFileTest(0x14000374340, {0x1400036fc70, 0xd}, {0x140001966b0, 0x1, 0x104be0098?})
	/Users/b/dev/gnoplay/gno/gnovm/tests/file_test.go:140 +0x1c8
github.com/gnolang/gno/gnovm/tests.runFileTests.func1(0x14000374340?)
	/Users/b/dev/gnoplay/gno/gnovm/tests/file_test.go:64 +0x38
@thehowl
Copy link
Member

thehowl commented Oct 21, 2024

This sounds like an error's that not supposed to be there, but not causing major disruption, so removing mainnet launch requirement.

@thehowl
Copy link
Member

thehowl commented Jan 21, 2025

No longer reproducible :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Development

No branches or pull requests

4 participants