Branch: refs/heads/main
Revision: ec3e91352515648d55957ebd9087ccd3d325e20b
Author: Michael Ferguson
Link: adjust disambiguation to prefer instantiating over implicitly converting by mppf · Pull Request #20755 · chapel-lang/chapel · GitHub
Log Message:
Experimental fix to 20539
Resolves #20539 Previous to this PR, unytped formals were less preferred that an implicit conversion. However, formals with a generic type were not. For example:
proc g(arg) { writeln("in generic g"); }
proc g(arg: real) { writeln("in real g"); }
g(1); // "in real g"
// but...
proc h(arg: integral) { writeln("in generic h"); }
proc h(arg: real) { writeln("in real h"); }
h(1); // "in generic h"
This PR adjusts the disambiguation code to only consider the "more generic" rule if the instantiated formal type is the same between the two formals being considered. Previously, it did this for dtAny but not for other generic types. The result is that, with the changes in this PR, the above program prints in generic g and in generic h. (This change primarily amounted to moving some code to determine a "more generic" preference inside of a conditional checking that the two formal types are the same). The main source of module code changes is for patterns where we had several overloads with detailed types and then a catch-all overload for "everything else". This PR adjusts module code in this situation in one of these ways (where it depends on the situation which adjustment was easier / made more sense): * using pragma "last resort" * using a where clause on the catch-all overload * combining several overloads into a single generic function Supporting changes in this PR: * adds PRIM_IS_BORROWED_CLASS_TYPE to help implement isBorrowedClassType in a straightforward way (it is tricky because non-borrow class types will implicitly convert into a borrow). Reviewed by @DanilaFe and @bradcray - thanks! - full local futures testing
Compare: Comparing 416db54050203c6fec2b9b9959083d9abde20b1d...ec3e91352515648d55957ebd9087ccd3d325e20b · chapel-lang/chapel · GitHub
Diff: https://github.com/chapel-lang/chapel/pull/20755.diff
Modified Files:
.github/workflows/email.yml,compiler/AST/checkAST.cpp,compiler/AST/primitive.cpp,compiler/include/resolution.h,compiler/passes/checkResolved.cpp,compiler/resolution/functionResolution.cpp,compiler/resolution/preFold.cpp,frontend/include/chpl/uast/prim-ops-list.h,frontend/lib/resolution/prims.cpp,modules/internal/ChapelArray.chpl,modules/internal/ChapelBase.chpl,modules/internal/ChapelDomain.chpl,modules/internal/ChapelRange.chpl,modules/internal/String.chpl,modules/packages/Crypto.chpl,modules/packages/Socket.chpl,modules/standard/AutoMath.chpl,modules/standard/IO.chpl,modules/standard/Types.chpl,test/functions/ferguson/type-colon-dispatch.chpl,test/gpu/native/studies/shoc/triadchpl.good,test/gpu/native/studies/shoc/triadchpl.gpu-keys,test/library/packages/Crypto.skipif,test/library/packages/Crypto/blowfish/bfTest1.good,test/library/packages/Crypto/blowfish/bfTest2.good,test/library/packages/Socket.skipif,test/library/packages/Socket/ipv6/connect_timeout_ipv6.chpl,test/library/packages/Socket/ipv6/udpio_ipv6.chpl,test/library/standard/Types/copyable-sync-string.bad,test/library/standard/Types/copyable-sync-string.chpl,test/library/standard/Types/copyable-sync-string.good,test/studies/dedup/dedup-extern.skipif,test/studies/dedup/dedup-externblock.skipif,test/trivial/deitz/coerce-assign/plusassign.chpl,test/trivial/deitz/coerce-assign/plusassign_error.good,test/trivial/deitz/type-param-mod-config/type_select1-handcode.good,test/types/coerce/allNumericsBinary.chpl,test/types/coerce/allNumericsBinaryBigParam.chpl,test/types/coerce/allNumericsBinaryBigParamParam.chpl,test/types/coerce/allNumericsBinaryParam.chpl,test/types/coerce/allNumericsBinaryParamParam.chpl,test/types/coerce/allNumericsBinaryRealImagComplex-compiles.chpl,test/types/coerce/allNumericsBinaryRealImagComplex-errors.chpl,test/types/coerce/allNumericsBinaryRealImagComplex-errors.good,test/types/coerce/allNumericsUnaryRealImagComplex.chpl,test/types/coerce/ferguson/coercion-dispatch-minimal-modules.good,test/types/imag/opequals2.1.good,test/types/imag/opequals2.2.good,test/types/sync/lydia/arrayOfArrayOfSyncsInField.bad,tools/mason/MasonUtils.chpl,util/buildRelease/smokeTest,util/devel/lookForTabs,util/devel/lookForTrailingSpaces
Added Files:
test/extern/ExternBlockClangError.skipif,test/library/packages/Crypto/blowfish.skipif,test/trivial/deitz/coerce-assign/plusassign_error.prediff,test/types/coerce/allNumericsBinaryWithGeneric.chpl,test/types/coerce/allNumericsBinaryWithGeneric.good,test/types/coerce/allNumericsUnaryRealImagComplexWithGeneric.chpl,test/types/coerce/allNumericsUnaryRealImagComplexWithGeneric.good,test/types/coerce/coerce-vs-generic.chpl,test/types/coerce/coerce-vs-generic.good,test/types/imag/opequals2.prediff,test/types/sync/lydia/arrayOfArrayOfSyncsInField.prediff
Removed Files: