-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix isolation analysis for start actions #42366
Fix isolation analysis for start actions #42366
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #42366 +/- ##
=============================================
+ Coverage 0.00% 76.73% +76.73%
- Complexity 0 53738 +53738
=============================================
Files 9 2907 +2898
Lines 35 203156 +203121
Branches 0 26484 +26484
=============================================
+ Hits 0 155883 +155883
- Misses 35 38754 +38719
- Partials 0 8519 +8519 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't seem to be logging a warning for
import ballerina/http;
type UserRegistration record {
string name;
string email;
};
class Obj {
int x = 1;
function fn() {
}
}
function getObj(Obj obj) returns Obj => obj;
service on new http:Listener(8080) {
resource function get h1(UserRegistration user) {
Obj obj = new;
_ = start sendEmailNotification(getObj(obj));
}
}
isolated function sendEmailNotification(object {} ob) returns error? {
}
...st/src/test/resources/test-src/isolation-analysis/isolation_warnings_for_service_methods.bal
Outdated
Show resolved
Hide resolved
This isn't fixed yet? |
Fixed in commit. |
if (this.inIsolatedStartAction | ||
&& !isSubtypeOfReadOnlyOrIsolatedObjectOrInferableObject(symbol.owner, symbol.getType())) { | ||
inferredIsolated = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this happen outside the outer check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the outside of the outer check we analyse symbols with recordFieldDefaultValue
and objectFieldDefaultValueRequiringIsolation
being true. For those I don't think we need to check its a subtype of readonly or isolated object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for those this.inIsolatedStartAction
won't be true, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But outer was there to handle both true
and false
scenarios. We have add this new check to validate start actions specifically. Which wasn't being analysed previously.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point is if we can't do
if (this.inIsolatedStartAction
&& !isSubtypeOfReadOnlyOrIsolatedObjectOrInferableObject(symbol.owner, symbol.getType())) {
inferredIsolated = false;
return;
}
outside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we need isReferenceToVarDefinedInSameInvokable
check as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example for when we need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I am running the test locally previously seems I haven't added the return
statement. We can move this to the outside of the outer if. Updated in commit.
@@ -4125,7 +4133,8 @@ private boolean inferFunctionIsolation(BSymbol symbol, IsolationInferenceInfo fu | |||
} | |||
|
|||
for (BLangExpression dependsOnArg : functionIsolationInferenceInfo.dependsOnFuncCallArgExprs) { | |||
if (!isIsolatedExpression(dependsOnArg)) { | |||
if (!isIsolatedExpression(dependsOnArg, false, false, new ArrayList<>(), true, | |||
publiclyExposedObjectTypes, classDefinitions, moduleLevelVariables, new HashSet<>())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we pass unresolvedSymbols
here? Shall we add a test too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing tests will cover this scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that should have resulted in a stack overflow-ish error, right? If we are recursively checking the isolated-ness of the same construct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example:
function fn(any x = ()) returns any {
_ = start fn(fn());
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
When we don't pass unresolved symbols, for the provided sample it gives SO.
...test/src/test/resources/test-src/isolation-analysis/isolation_analysis_for_async_actions.bal
Show resolved
Hide resolved
aef9b04
to
4ec4938
Compare
0a7e4c9
into
ballerina-platform:master
Purpose
$subject
FIxes #41691
Related PR #41772
Approach
Samples
Remarks
This PR includes only fixing isolation analysis with start actions. The compiler crashes happens when passing mapping and list constructors will be fixed by #41772.
Check List