Branch: refs/heads/main
Revision: 1914f5ff352158869ca16b3a3f53edcb0cec339f
Author: DanilaFe
Link: Dyno: emit error for failed implicit 'super' calls by DanilaFe · Pull Request #26630 · chapel-lang/chapel · GitHub
Log Message:
Dyno: emit error for failed implicit 'super' calls (#26630)
Closes https://github.com/Cray/chapel-private/issues/6722, which asks to
emit an error when a call to 'super' is implicitly inserted but fails to
resolve:
class Parent {
var x : int = 42;
proc init(x: int) {
this.x = x;
}
}
class Child : Parent {
var y : string;
proc init() {
// tries to resolve 'super.init()', but parent 'init' requires an argument!
this.y = x:string;
}
}
This PR performs a relatively major re-architecture of the way that
calls are resolved and noted as part of Dyno's resolver, which reduces
the effort (at call sites) to handle the results of these calls. This
stemmed from the observation that a variety of resolver functions for
call resolution have nearly 10 arguments, and thread through the same
state that's passed in when a call is first resolved. For instance, a
user might perform resolveGeneratedCall
, then call
handleResolvedCallPrintCandidates,
which will in turn call
handleResolvedCallWithoutError
, etc. To invoke these helpers, the user
would need to re-pass the call info, scope information, a boolean
indicating if the call was generated, and much more to these functions.
Not only that, but these invocations to handle*
were not always
performed, even though they are instrumental to tracking compilerError
information and noting PoI scope info.
This PR creates wrappers around the various call resolution procedures
from resolution-queries.h
that bundle together the result of resolving
the call with the information needed to note it etc., via a new type.
This new type exposes methods analogous to
handleResolvedCallPrintCandidates
, except they do not require
re-threading through of the 10 arguments that were previously needed.
This new type also has some state (in the form of callName
and
reportFunction
) which can be used to customize the behavior of error
reporting. In the case of the new error message added by this PR, the
reporting function is used to issue a NoMatchingSuper
error, which
contains additional data and is used for a very detailed explanation of
what went wrong.
Reviewed by @benharsh -- thanks!
Testing
- dyno. tests
- paratest
Diff:
M frontend/include/chpl/resolution/resolution-error-classes-list.h
M frontend/lib/resolution/InitResolver.cpp
M frontend/lib/resolution/InitResolver.h
M frontend/lib/resolution/Resolver.cpp
M frontend/lib/resolution/Resolver.h
M frontend/lib/resolution/call-init-deinit.cpp
M frontend/lib/resolution/resolution-error-classes-list.cpp
M frontend/test/resolution/testInitSemantics.cpp
M frontend/test/resolution/testResolverVerboseErrors.cpp
https://github.com/chapel-lang/chapel/pull/26630.diff