Commit 9bba297
Emit Hole for Composite return values assigned to Any (#727)
### Problem
When a Python function returns a Composite-typed value (e.g., a service
client) but the Laurel return variable `LaurelResult` has type `Any`,
Core type checking fails with "Impossible to unify Any with Composite".
### Approach
Per design discussion with @keyboardDrummer and @joehendrix: emit a Hole
(unconstrained value) when a Composite-typed expression is returned from
a function with Any return type. This avoids the type unification
crash while being honest about the limitation — the verifier treats the
return value as unconstrained, which limits bug-finding but doesn't
produce unsound results.
Auto-generated Composite -> Any coercions can be revisited once the
broader Composite/Any typing design is resolved.
**Changes:**
- Add `coerceToAny` helper that replaces Composite-typed expressions
with a Hole when assigned to an Any-typed context
- Apply coercion in return statement translation before assigning to
`LaurelResult`
- Add regression tests in `VerifyPythonTest.lean` and CBMC pipeline
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
---------
Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Co-authored-by: Shilpi Goel <shigoel@gmail.com>1 parent 8881eb5 commit 9bba297
4 files changed
Lines changed: 46 additions & 0 deletions
File tree
- StrataTest/Languages/Python
- tests
- Strata/Languages/Python
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
741 | 752 | | |
742 | 753 | | |
743 | 754 | | |
| |||
1207 | 1218 | | |
1208 | 1219 | | |
1209 | 1220 | | |
| 1221 | + | |
| 1222 | + | |
1210 | 1223 | | |
1211 | 1224 | | |
1212 | 1225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
133 | 154 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
0 commit comments