fix: FunctionDef does not emit a return for void functions#252
Conversation
|
Hey @yuvimittal , I tested the changes locally — all 5 tests pass . hey @Fizza-Mukhtar ,same as your other PR , the branch is a bit behind main so you'll probably need a rebase to avoid conflicts |
|
@Fizza-Mukhtar , overall tests are good, just one comment |
| main_fn = astx.FunctionDef(prototype=main_proto, body=main_body) | ||
| module.block.append(main_fn) | ||
|
|
||
| check_result("build", builder, module) |
There was a problem hiding this comment.
This does not guarantee correct IR, only that it didn’t crash.
There was a problem hiding this comment.
Updated the test to verify ret void is present in the emitted IR
instead of only checking that the build did not crash. Also rebased
onto latest main.
ddd0ca0 to
42ca66d
Compare
42ca66d to
eecf504
Compare
|
🎉 This PR is included in version 1.9.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Pull Request description
Fixes #244
When
visit(FunctionDef)finishes walking the function body, if noFunctionReturnnode was encountered the current basic block is leftwithout a terminator. llvmlite raises an
AssertionErrorduring moduleverification for void functions, and silently produces malformed IR for
non-void functions that fall off the end.
Fix: after
self.visit(node.body), checkis_terminatedon thecurrent block:
ret_void()ret <zero>as a safe fallbackHow to test these changes
Pull Request checklists
This PR is a:
About this PR:
Author's checklist: