Came up in a query related to isolated, where we try to use self as a captured variable in an isolated anonymous function within a method of a readonly class.
readonly class Test {
string[] words;
int length;
isolated function init(string[] & readonly words, int length) {
self.words = words;
self.length = length;
}
isolated function getCount() returns int {
var fn = isolated function(string word) returns boolean {
// ERROR: invalid access of `self`
return word.length() == self.length;
};
return self.words.filter(fn).length();
}
}
The jBallerina implementation also doesn't seem to log a compilation error when trying to assign a value to self at the moment.
readonly class Class {
int i;
function init(int i) {
self.i = i;
}
function fn() {
// no compilation error on jBallerina
self = new (3);
}
}
Description: $title.
Came up in a query related to
isolated
, where we try to useself
as a captured variable in an isolated anonymous function within a method of areadonly
class.The jBallerina implementation also doesn't seem to log a compilation error when trying to assign a value to
self
at the moment.