feat: Provide a more precise error message when missed return statement is inside branch#1486
Conversation
|
| Branch | na/issue1348-error-message-for-missing-return |
| Testbed | Linux |
Click to view all benchmark results
| Benchmark | hugr_bytes | Benchmark Result bytes x 1e3 (Result Δ%) | Upper Boundary bytes x 1e3 (Limit %) | hugr_nodes | Benchmark Result nodes (Result Δ%) | Upper Boundary nodes (Limit %) |
|---|---|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | 📈 view plot 🚷 view threshold | 140.94 x 1e3(0.00%)Baseline: 140.94 x 1e3 | 142.35 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 6,592.00(0.00%)Baseline: 6,592.00 | 6,657.92 (99.01%) |
| tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile | 📈 view plot 🚷 view threshold | 18.59 x 1e3(0.00%)Baseline: 18.59 x 1e3 | 18.78 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 608.00(0.00%)Baseline: 608.00 | 614.08 (99.01%) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1486 +/- ##
==========================================
- Coverage 93.54% 93.39% -0.15%
==========================================
Files 127 128 +1
Lines 11797 12004 +207
==========================================
+ Hits 11035 11211 +176
- Misses 762 793 +31 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I have refactored the error point search; it should be better now. I also added a couple of extra test cases |
|
I also moved the test files to |
mark-koch
left a comment
There was a problem hiding this comment.
Thanks, the new algorithm is looking a lot better! Also sorry for the long delay in getting back to you 😅
| # Best solution here is give up on finding the missing return point, | ||
| # considering node[-1] as error point | ||
| # together with the help on the branch condition. | ||
| return None, (fbb_ancestor.branch_pred, 0) |
There was a problem hiding this comment.
Why is it always 0 here?
There was a problem hiding this comment.
Because if the return is inside the loop, the best suggestion we suggest to add a return when the loop condition is false. Added in the comment explanation.
mark-koch
left a comment
There was a problem hiding this comment.
Thanks, looks good to me!
buildfunction inbuilder.pynow locates the specific statement and branch condition where a return statement is missingExpectedErrorclass now includes aBranchnoteclose #1348