Branch: refs/heads/master
Revision: 9e24475
Author: bradcray
Log Message:
Merge pull request #17646 from bradcray/make-cond-test-a-method
Make _cond_test
a method for library-based types
[reviewed by @vasslitvinov]
This PR addresses an issue in which import
ing a module with a type that can be used in conditionals could cause those conditionals to break. The reason for the issue is that we implement such checks as standalone functions (named _cond_test
) and such standalone functions aren't brought into scope for import
clauses unless they're named.
The fix I took here (which came out of a conversation with @mppf and @lydia-duncan) was to make these routines methods on the types in question (named chpl_cond_test_method
so that any instance of the object would automatically have access to the method. To minimize the number of code changes required, I took the approach of checking for the presence of the method in the error overload of _cond_test
and calling it if it existed (issuing the usual error if it does not). This avoided changes to the compiler and to the existing _cond_test
implementations for automatic types (bools, ints, strings, etc.)
Going forward, we will want to consider whether user-defined types should be able to define themselves as being legal to use in a conditional which I've spun off into Should user-defined types be able to used in conditionals? And if so, how? · Issue #17645 · chapel-lang/chapel · GitHub.
Resolves #17633
Modified Files:
A test/errhandling/importConditionalSysErr.chpl
A test/errhandling/importConditionalSysErr.good
A test/interop/C/importConditionalCPtr.chpl
A test/interop/C/importConditionalCPtr.good
A test/regex/importConditional.chpl
A test/regex/importConditional.good
M modules/internal/ChapelBase.chpl
M modules/standard/CPtr.chpl
M modules/standard/Regex.chpl
M modules/standard/SysBasic.chpl
M test/modules/bradc/printModStuff/foo.good
Compare: https://github.com/chapel-lang/chapel/compare/d42d9c50a99d...9e24475a07c3