tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

panic: unimplemented: (reflect.Value).MapRange()

Open kishorekonjeti opened this issue 3 years ago • 1 comments

I haven't used any relection in my code below. But still getting the issue. But the same working fine with official go compiler. not sure even for small lines of code also its not working. Can some one look on to this.?

  • OS: ubuntu
  • tinygo : version 0.25
  • go version : 1.19
package main

import "fmt"

func main() {

	// Creating and initializing a map
	m_a_p := map[int]string{
		90: "Dog",
		}

	fmt.Println("Original map: ", m_a_p)

	// Checking the key is available
	// or not in the m_a_p map
	pet_name, ok := m_a_p[90]
	fmt.Println("\nKey present or not:", ok)
	fmt.Println("Value:", pet_name)
	 
}
$ tinygo build map_chk.go 
./map_chk
getting error message as 
**panic: unimplemented: (reflect.Value).MapRange()
Aborted (core dumped)**

kishorekonjeti avatar Aug 30 '22 15:08 kishorekonjeti

You are actually using reflection, here:

	fmt.Println("Original map: ", m_a_p)

The fmt package uses reflection to read the values it is given. But because MapRange isn't implemented, it crashes. Removing this line will likely get your program to work.

aykevl avatar Sep 08 '22 14:09 aykevl

My recent reflect work #3470 adds this call.

dgryski avatar Feb 24 '23 21:02 dgryski

This now works:

~/go/src/github.com/dgryski/bug/m $ go run main.go
Original map:  map[90:Dog]

Key present or not: true
Value: Dog
~/go/src/github.com/dgryski/bug/m $ tinygo run main.go
Original map:  map[90:Dog]

Key present or not: true
Value: Dog

dgryski avatar Mar 23 '23 05:03 dgryski

This is part of the v0.28 release so now closing this issue. Thanks!

deadprogram avatar Jun 14 '23 08:06 deadprogram