Skip to content

Commit

Permalink
Update the top level check
Browse files Browse the repository at this point in the history
  • Loading branch information
poorna2152 committed Nov 27, 2023
1 parent 87e9ce5 commit f2bfbf4
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1510,15 +1510,15 @@ public void visit(BLangWhile whileNode, AnalyzerData data) {
public void visit(BLangDo doNode, AnalyzerData data) {
boolean onFailExists = doNode.onFailClause != null;
boolean failureHandled = data.failureHandled;
boolean previousWithinDoBlock = data.withinDoBlock;
data.withinDoBlock = true;
boolean previousWithinDoBlock = data.withinWorkerTopLevelDo;
data.withinWorkerTopLevelDo = isCommunicationAllowedLocation(data.env) && isInWorker(data.env);
if (onFailExists) {
data.failureHandled = true;
}
analyzeNode(doNode.body, data);
data.failureHandled = failureHandled;
analyseOnFailClause(onFailExists, doNode.onFailClause, data);
data.withinDoBlock = previousWithinDoBlock;
data.withinWorkerTopLevelDo = previousWithinDoBlock;
}


Expand Down Expand Up @@ -2005,7 +2005,7 @@ public void visit(BLangWorkerAsyncSendExpr asyncSendExpr, AnalyzerData data) {
}

String workerName = asyncSendExpr.workerIdentifier.getValue();
if (!data.withinDoBlock && (data.withinQuery ||
if (!data.withinWorkerTopLevelDo && (data.withinQuery ||
(!isCommunicationAllowedLocation(data.env) && !data.inInternallyDefinedBlockStmt))) {
this.dlog.error(asyncSendExpr.pos, DiagnosticErrorCode.UNSUPPORTED_WORKER_SEND_POSITION);
was.hasErrors = true;
Expand Down Expand Up @@ -2065,7 +2065,7 @@ public void visit(BLangWorkerSyncSendExpr syncSendExpr, AnalyzerData data) {
was.hasErrors = true;
}

if (!data.withinDoBlock && (data.withinQuery ||
if (!data.withinWorkerTopLevelDo && (data.withinQuery ||
(!isCommunicationAllowedLocation(data.env) && !data.inInternallyDefinedBlockStmt))) {
this.dlog.error(syncSendExpr.pos, DiagnosticErrorCode.UNSUPPORTED_WORKER_SEND_POSITION);
was.hasErrors = true;
Expand Down Expand Up @@ -4261,7 +4261,7 @@ public static class AnalyzerData {
boolean loopAlterNotAllowed;
// Fields related to worker system
boolean inInternallyDefinedBlockStmt;
boolean withinDoBlock;
boolean withinWorkerTopLevelDo;
int workerSystemMovementSequence;
Stack<WorkerActionSystem> workerActionSystemStack = new Stack<>();
Map<BSymbol, Set<BLangNode>> workerReferences = new HashMap<>();
Expand Down

0 comments on commit f2bfbf4

Please sign in to comment.