Commit f368f26
Meghan Lele
[JIT] Check mergeability of return types for functions that return Any
**Summary**
This commit modifies the type checking performed during IR generation so
that it checks that all return types for a function marked as returning
`Any` can be unified.
Issue #41962 reported that the use of an `Any` return type in
combination with different code paths returning values of different
types causes a segmentation fault. During IR generation, the type of
each return is checked against the annotated return type of the
function, or unified with all other return types if there is no
annotation. Because every type is a subtype of `Any`, this commit
modifies the IR generation to do the latter (i.e. check if all return
types can be unified) if the annotated return type is `Any`.
**Test Plan**
This commit adds a unit test that checks that an exception with an
appropriate error message is thrown when a function and module with an
annotated return type of `Any` is compiled and the possible return types
cannot be unified.
**Fixes**
This commit fixes #41962.
ghstack-source-id: bc3ca78
Pull Request resolved: #422591 parent 27b03d6 commit f368f26
2 files changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
533 | 534 | | |
534 | 535 | | |
535 | 536 | | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
536 | 569 | | |
537 | 570 | | |
538 | 571 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
956 | 956 | | |
957 | 957 | | |
958 | 958 | | |
959 | | - | |
| 959 | + | |
960 | 960 | | |
961 | 961 | | |
962 | 962 | | |
| |||
0 commit comments