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

map(int,["1","2"]) convert wrong #14

Open
asukaminato0721 opened this issue Feb 23, 2022 · 0 comments
Open

map(int,["1","2"]) convert wrong #14

asukaminato0721 opened this issue Feb 23, 2022 · 0 comments

Comments

@asukaminato0721
Copy link

Describe the bug
A clear and concise description of what the bug is.

map(int,["1","2"]) convert wrong

Python code example
The simplest possible Python code example to demonstrate the bug.

def main():
  x=map(int,["1","2"])
  print(x)

if __name__ == '__main__':
  main()

Current behavior
What the program currently outputs for the code example.

package main

import "fmt"

func main() {
	x := func() func() <-chan int {
		wait := make(chan struct{})
		yield := make(chan int)
		go func() {
			defer close(yield)
			<-wait
			for _, x := range []string{"1", "2"} {
				yield <- int(x)
				<-wait
			}
		}()
		return func() <-chan int {
			wait <- struct{}{}
			return yield
		}
	}()
	fmt.Println(x)
}

Expected behavior
A clear and concise description of what you expected to happen.

int should be translated.

Go code example
Optional. An example of a satisfactory Go code output for the Python example.

def main():
  print(int("1"))
if __name__ == '__main__':
  main()

this returns a good result.

package main

import (
	"fmt"
	"strconv"
)

func main() {
	fmt.Println(func() int {
		i, err := strconv.ParseInt("1", 10, 64)
		if err != nil {
			panic(err)
		}
		return int(i)
	}())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant