Skip to content

Commit

Permalink
Merge pull request #42503 from MaryamZi/disallow-error-bp-in-on-fail
Browse files Browse the repository at this point in the history
Disallow error binding patterns in on fail clauses temporarily (for U9)
  • Loading branch information
LakshanWeerasinghe authored Apr 8, 2024
2 parents 73d7f77 + 6ceaa3b commit d89ece4
Show file tree
Hide file tree
Showing 19 changed files with 2,778 additions and 2,708 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ public enum DiagnosticErrorCode implements DiagnosticCode {
EXPRESSION_OF_FUTURE_TYPE_EXPECTED("BCE4057", "future.expression.expected"),
INSTANTIATION_ERROR("BCE4058", "instantiation.error"),
INVALID_BINDING_PATTERN_IN_ON_FAIL("BCE4059", "invalid.binding.pattern.in.on.fail"),
ERROR_BINDING_PATTERN_NOT_YET_SUPPORTED_IN_ON_FAIL("BCE4060", "error.binding.pattern.not.yet.supported.in.on.fail")
;

private String diagnosticId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3907,6 +3907,7 @@ public void visit(BLangOnFailClause onFailClause, AnalyzerData data) {
Names.fromString(anonModelHelper.getNextErrorVarKey(
onFailEnv.enclPkg.packageID)),
onFailEnv, true);
dlog.error(errorVar.pos, DiagnosticErrorCode.ERROR_BINDING_PATTERN_NOT_YET_SUPPORTED_IN_ON_FAIL);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2031,3 +2031,6 @@ error.inferred.query.construct.type.as.stream=\

error.invalid.binding.pattern.in.on.fail=\
invalid binding pattern in ''on fail'' clause: only a capture binding pattern or an error binding pattern is allowed

error.error.binding.pattern.not.yet.supported.in.on.fail=\
error binding patterns are not yet supported in ''on fail'' clauses
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public void testForeachSemanticsNegative() {
"mismatch with member type count", 342, 13);
BAssertUtil.validateError(compile, index++, "invalid list binding pattern; member variable count " +
"mismatch with member type count", 346, 18);
BAssertUtil.validateError(compile, index++, "error binding patterns are not yet supported in " +
"'on fail' clauses", 374, 15);
BAssertUtil.validateError(compile, index++, "invalid error variable; expecting an error type " +
"but found '(SampleComplexError|SampleError)' in type definition", 374, 15);
Assert.assertEquals(compile.getErrorCount(), index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void testNestedWhileStmtWithFail() {
Assert.assertEquals(result.toString(), expected);
}

@Test(dataProvider = "onFailClauseWithErrorBPTestDataProvider")
@Test(dataProvider = "onFailClauseWithErrorBPTestDataProvider", enabled = false)
public void testOnFailWithErrorBP(String funcName) {
BRunUtil.invoke(program, funcName);
}
Expand Down
Loading

0 comments on commit d89ece4

Please sign in to comment.