Commit 04f033c
committed
overload: Prefer passing literal 0 to ints instead of ptrs
hCalcTypesDiff() used to just return a FB_OVLPROC_HALFMATCH score when
passing a literal zero with some integer type to a pointer parameter.
This meant that such matches would have higher scores than any
int-to-int matches (e.g. passing a literal zero of some integer type to
some integer parameter), because those are scored via
FB_OVLPROC_HALFMATCH - symb_dtypeMatchTB..., which will always produce
lower values than FB_OVLPROC_HALFMATCH.
However, I think that integer parameters should be preferred over pointer
parameters when passing in an integer argument (even if it's a literal 0).
Thus hCalcTypesDiff() now returns 1 instead of FB_OVLPROC_HALFMATCH when
passing a literal 0 to a pointer. This case should still be allowed, but
just rated lower than normal integer-to-integer matches. Thus it will only
be the last resort, not the first choice.1 parent dcf88c5 commit 04f033c
File tree
4 files changed
+80
-5
lines changed- src/compiler
- tests/overload
4 files changed
+80
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1718 | 1718 | | |
1719 | 1719 | | |
1720 | 1720 | | |
1721 | | - | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
1722 | 1728 | | |
1723 | 1729 | | |
1724 | 1730 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | 14 | | |
18 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
794 | 860 | | |
795 | 861 | | |
796 | 862 | | |
| |||
832 | 898 | | |
833 | 899 | | |
834 | 900 | | |
| 901 | + | |
| 902 | + | |
835 | 903 | | |
836 | 904 | | |
837 | 905 | | |
0 commit comments