microsoft / microsoft/pxt-microbit
Python editor gives error with lambdas
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
Describe the bug
Lambda variables are treated as non-callable. Upon creating a lambda, trying to call it I receive an error stating that I'm trying to "Call a non-function".
To Reproduce
f = lambda x: x*x
basic.show_number(f(2))
Error: Line 2: calling non-function
This happens even when annotating f with : function
Expected behavior
Lambdas working
Desktop:
- OS: Linux
- Browser: Mozilla Firefox 80.0.1
Additional context
Error appears both on master branch, and live version.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the Python editor by reproducing the reported lambda snippet and tracing how the editor determines whether a variable is callable. Verify both the unannotated and function-annotated forms, and consider the work complete when calling the lambda no longer reports “calling non-function” and the example displays 4.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- devtools, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100