Branch: refs/heads/main
Revision: 76a5b0169e4dbbe35a51f1732b94228c9d210f3e
Author: bradcray
Link: Improve error messages for bad where clauses by bradcray · Pull Request #28889 · chapel-lang/chapel · GitHub
Log Message:
Improve error messages for bad where clauses (#28889)
[reviewed by @DanilaFe]
This is a simple approach to improving where clause errors by
leveraging a (new) internal module helper routine that checks whether
the expression is a param bool or not and generates a helpful error
when it's not.
The implementation is complicated somewhat by implements clauses, as
the compiler's processing of them assumes a certain structural
form—either that the implements is the top-level expression, or that
it's part of an && expression. Here, I updated the pass that pulls
implements clauses out of where clauses to reflect the new structure
caused by the helper routine.
Implementation essentially involved:
- adding the helper routine,
chpl_validateWhere()to
modules/internal/ChapelBase.chpl - adding a call to it in
compiler/AST/build.cpp - removing the old, vague compiler-generated messages about badly-formed
whereclauses fromcompiler/resolution/generics.cpp, as the new ones
supercede them - updating the processing of
implementsin
compiler/passes/normalize.cppto be aware of the new structure - I also added more failure messages in the event that the structure is
not as expected where before, they could seemingly fall through silently
in some cases(?) - adding tests from #28882 to lock in behavior and updating tests that
used the old error message wording
Resolves #28882
Diff:
M compiler/AST/build.cpp
M compiler/passes/normalize.cpp
M compiler/resolution/generics.cpp
M modules/internal/ChapelBase.chpl
M test/functions/diten/badwhere.good
A test/functions/whereClauses/whereClauseIntAndArrayArg.chpl
A test/functions/whereClauses/whereClauseIntAndArrayArg.good
M test/functions/whereClauses/whereClauseNonParam.good
M test/functions/whereClauses/whereClauseNonParamGeneric.good
A test/functions/whereClauses/whereClauseReal.chpl
A test/functions/whereClauses/whereClauseReal.good
A test/functions/whereClauses/whereClauseRealAndArrayArg.chpl
A test/functions/whereClauses/whereClauseRealAndArrayArg.good
https://github.com/chapel-lang/chapel/pull/28889.diff