Open malinthar opened 2 years ago
Seems to be an issue related to closure resolving related to https://github.com/ballerina-platform/ballerina-lang/issues/32710 Please try out the work-around below
import ballerina/time;
import ballerina/io;
type ExchangeRate record {|
string 'from;
string to;
string date;
decimal rate;
|};
type Response record {
boolean success;
decimal result;
};
public type Subscriber record {|
readonly string mobileNumber;
readonly Conversion[] conversions;
|};
type Conversion record {|
string to;
string 'from;
|};
class Job {
private map<Subscriber> subscribers;
private map<string[]> conversions;
isolated function init() {
self.subscribers = {};
self.conversions = {};
}
function getRatesAndSendSms(string date) returns error? {
map<ExchangeRate[]> currentRates = {};
check from Subscriber subscriber in self.subscribers
do {
ExchangeRate[] subscribedRates = [];
check from Conversion conversion in subscriber.conversions
let string conversionToVal = conversion.to //binding the erroneous closure symbol to a temp variable
do {
if currentRates.hasKey(conversion.'from) {
ExchangeRate rate = currentRates.get(conversion.'from)
.filter(exchageRate => exchageRate.to.equalsIgnoreCaseAscii(conversionToVal)).pop();
subscribedRates.push(rate);
}
};
};
}
}
public function main() {
string date = string:substring(time:utcToString(time:utcNow()), 0, 10);
Job job = new ();
error? ratesAndSendSms = job.getRatesAndSendSms(date);
if ratesAndSendSms is error {
io:print(ratesAndSendSms.message());
}
}
Description: Consider the following program
I get the following stack trace when trying to run the following program.
The issue seems to be with the query expression in the
getRatesAndSendSms
method. When I remove it the program runs without an issue.Steps to reproduce: Run the above program
Affected Versions: 2201.2.0-rc2