pytago icon indicating copy to clipboard operation
pytago copied to clipboard

decorator convert wrong

Open asukaminato0721 opened this issue 2 years ago • 0 comments

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

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

def main():
  def test(f):
    def inner(*args):
      print(args)
      f(*args)
    return inner
  @test
  def x(a,b):
    return a,b
  x(1,2)

if __name__ == '__main__':
  main()

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

package main

import "fmt"

func main() {
	test := func(f interface{}) {
		inner := func() {
			fmt.Println(args)
			f(args...)
		}
		inner
	}
	x := func(a int, b int) [2]int {
		return [2]int{a, b}
	}
	x(1, 2)
}

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

the decorator changes the function's behavior.

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

asukaminato0721 avatar Feb 23 '22 10:02 asukaminato0721