Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed May 15, 2023
2 parents 5670ff0 + 79450aa commit ad18c25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4737,12 +4737,14 @@ private void setEventualTypeForExpression(BLangExpression expression,
if (isSimpleWorkerReference(expression, data)) {
return;
}
if (expression.expectedType.tag != TypeTags.FUTURE) {
dlog.error(expression.pos, DiagnosticErrorCode.EXPRESSION_OF_FUTURE_TYPE_EXPECTED);

BType expectedType = expression.expectedType;
if (expectedType.tag != TypeTags.FUTURE) {
dlog.error(expression.pos, DiagnosticErrorCode.EXPRESSION_OF_FUTURE_TYPE_EXPECTED, expectedType);
return;
}

BFutureType futureType = (BFutureType) expression.expectedType;
BFutureType futureType = (BFutureType) expectedType;
BType currentType = futureType.constraint;
if (types.containsErrorType(currentType)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,21 @@ public void testNegativeWorkerActions() {
"incompatible types: expected 'string', found eventual type '(string|error)' for wait future " +
"expression 'f4'", 90, 54);
BAssertUtil.validateError(resultNegative, index++,
"cannot use an alternate wait action within a multiple wait action",
123, 38);
"cannot use an alternate wait action within a multiple wait action", 115, 38);
BAssertUtil.validateError(resultNegative, index++,
"cannot use an alternate wait action within a multiple wait action",
124, 48);
"cannot use an alternate wait action within a multiple wait action", 116, 48);
BAssertUtil.validateError(resultNegative, index++,
"cannot use an alternate wait action within a multiple wait action",
125, 27);
"cannot use an alternate wait action within a multiple wait action", 117, 27);
BAssertUtil.validateError(resultNegative, index++,
"cannot use an alternate wait action within a multiple wait action",
125, 58);
BAssertUtil.validateError(resultNegative, index++,
"expression of future type is expected", 141, 38);
BAssertUtil.validateError(resultNegative, index++,
"expression of future type is expected", 142, 48);
BAssertUtil.validateError(resultNegative, index++,
"expression of future type is expected", 143, 27);
BAssertUtil.validateError(resultNegative, index++,
"expression of future type is expected", 143, 40);
"cannot use an alternate wait action within a multiple wait action", 117, 58);
BAssertUtil.validateError(resultNegative, index++, "expected an expression of type 'future'," +
" found '(future<(boolean|error)>|future<(boolean|error)>)'", 132, 38);
BAssertUtil.validateError(resultNegative, index++, "expected an expression of type 'future'," +
" found '(future<boolean>|future<boolean>)'", 133, 48);
BAssertUtil.validateError(resultNegative, index++, "expected an expression of type 'future'," +
" found '(future<(boolean|error)>|future<(boolean|error)>)'", 134, 27);
BAssertUtil.validateError(resultNegative, index++, "expected an expression of type 'future'," +
" found '(future<boolean>|future<boolean>)'", 134, 40);
Assert.assertEquals(resultNegative.getErrorCount(), index, "Wait actions negative test error count");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,18 @@ type WaitResult record {|

function waitForAllTest2() {
worker Producer1 returns boolean|error {
int i = 100;
i -> Consumer;
error? unionResult = flush Consumer1;
return true;
}

worker Producer2 returns boolean|error {
int i = 100;
i -> Consumer;
error? unionResult = flush Consumer1;
return true;
}

worker Consumer1 returns boolean {
int i = <- Producer;
return false;
}

worker Consumer2 returns boolean {
int i = <- Producer;
return false;
}

Expand All @@ -131,7 +123,6 @@ function waitActionWithInvalidType() {
}

worker Consumer1 returns boolean {
int i = <- Producer;
return false;
}

Expand Down

0 comments on commit ad18c25

Please sign in to comment.