Fixes a bug when assigning a function to an intermediate variable #327
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Category
Description
Fixes a bug when assigning a function to an intermediate variable. Warp's code generator currently doesn't handle this pattern correctly. When a function is returned, the code generator replaces the expression with a special AST node (
ast.Name) with an identifier__warp_func__and attaches the actual function object to it using an attributewarp_func.In the example repro below from the doc, when the code generator later encounters the name
funcinoutput[tid] = func(a, b), it tries to resolvefuncbut fails because it doesn't find__warp_func__in its symbol table, leading to the error.NOTE: All tests pass, including the newly added test. However, please review carefully. Fingers crossed my tweaks don't unleash chaos.
Changelog
Before your PR is "Ready for review"
stubs.py,functions.rst)?ruff checkandruff format --check?