Rename Any_to_bool to python_is_truthy and add construct support#669
Draft
joehendrix wants to merge 2 commits intomainfrom
Draft
Rename Any_to_bool to python_is_truthy and add construct support#669joehendrix wants to merge 2 commits intomainfrom
joehendrix wants to merge 2 commits intomainfrom
Conversation
Rename the truthiness function from Any_to_bool to python_is_truthy in the prelude and all call sites (PAnd, POr, IfThenElse, While, Assert). Add support for previously unsupported Python constructs: - PPow (** operator) - FormattedValue (f-string interpolation) - Slice expressions Fix exception variable typing: use Any instead of PythonError (which is a Composite type incompatible with the Any-typed exception handling). Refactor AugAssign to throw on unsupported operators instead of silently emitting Hole. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 6 end-to-end tests exercising the new construct translations: - test_ternary.py: ternary conditional with python_is_truthy - test_pow_operator.py: ** operator (PPow) - test_fstring.py: f-string interpolation (FormattedValue) - test_slice.py: list slicing (Slice) - test_augassign.py: augmented assignment (+=) - test_except_var_usage.py: exception variable typed as Any Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Any_to_bool→python_is_truthy: More descriptive name for the Python truthiness function. Updated in prelude definition, PAnd/POr callers, and all PythonToLaurel call sites (IfThenElse, While, Assert).PPow(**operator),FormattedValue(f-string interpolation),Sliceexpressions — all previously threw "unsupported construct" errors.exceptclauses now useAnytype instead ofPythonError(a Composite type), fixing type mismatches in the Any-typed pipeline.Test plan
lake buildpasses cleanlyBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
🤖 Generated with Claude Code