type ClientError distinct error;
type ListenerError distinct error;
type PayloadBindingError distinct ClientError | distinct ListenerError;
type DistinctClientError distinct ClientError;
type DistinctClientError1 DistinctClientError;
type DistinctClientError2 distinct ClientError;
function getGenericClientError() returns ClientError {
return error DistinctClientError("Whoops!");
}
public function main() {
var r = getGenericClientError();
_ = r is DistinctClientError; // no hint, correct
_ = r is distinct ClientError; // gives hint "unnecessary condition: expression will always evaluate to 'true'", this is wrong
_ = r is DistinctClientError1; // no hint, correct
_ = r is DistinctClientError2; // no hint, correct
if (r is distinct ClientError) {
_ = 2;
} else {
_ = 3; // gives wrong compilation error: unreachable code
}
DistinctClientError err = error DistinctClientError("err");
_ = err is PayloadBindingError; // gives hint "unnecessary condition: expression will always evaluate to 'true'", this is wrong
}
gives
Compiling source
iss.bal
HINT [iss.bal:(19:9,19:34)] unnecessary condition: expression will always evaluate to 'true'
HINT [iss.bal:(23:9,23:34)] unnecessary condition: expression will always evaluate to 'true'
ERROR [iss.bal:(26:9,26:15)] unreachable code
HINT [iss.bal:(30:9,30:35)] unnecessary condition: expression will always evaluate to 'true'
error: compilation contains errors
Description
$title
Steps to Reproduce
gives
Affected Version(s)
Ballerina 2201.2.0 (Swan Lake Update 2)
OS, DB, other environment details and versions
No response
Related area
-> Compilation
Related issue(s) (optional)
https://github.com/ballerina-platform/ballerina-lang/issues/36142
Suggested label(s) (optional)
No response
Suggested assignee(s) (optional)
No response