microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
478 stars 207 forks source link

Cannot define higher order functions in Python #1927

Open darzu opened 4 years ago

darzu commented 4 years ago

This TS:

function foo(bar: (n: number) => number): number {
    return bar(3)
}

produces this PY:

def foo(bar: (number) -> number):
    return bar(3)

with these errors:

error: main.py(1,22): error TS9553: expecting ')' near `->`
error: main.py(1,25): error TS9553: expecting ':' near `number`
error: main.py(1,31): error TS9555: unexpected token near `)`
error: main.py(1,32): error TS9553: expecting <nl> near `:`
error: main.py(2,5): error TS9573: unexpected indent near `return`
error: main.py(2,12): error TS9508: can't find called function "bar"
error: main.py(2,12): error TS9516: name 'bar' is not defined
abchatra commented 1 year ago

Still repros.