Skip to content

Commit

Permalink
Merge pull request ballerina-platform#41545 from HindujaB/fix-config-…
Browse files Browse the repository at this point in the history
…compiler-error

Fix throwing unnecessary configurable compilation error
  • Loading branch information
warunalakshitha authored Nov 15, 2023
2 parents 57e2a4f + 6a89bf0 commit 4c27c5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1156,9 +1156,8 @@ public void visit(BLangSimpleVariable varNode, AnalyzerData data) {

BType lhsType = varNode.symbol.type;
varNode.setBType(lhsType);

// Configurable variable type must be a subtype of anydata.
if (configurable && varNode.typeNode != null) {
if (configurable && varNode.typeNode != null && lhsType.tag != TypeTags.SEMANTIC_ERROR) {
if (!types.isAssignable(lhsType, symTable.anydataType)) {
dlog.error(varNode.typeNode.pos,
DiagnosticErrorCode.CONFIGURABLE_VARIABLE_MUST_BE_ANYDATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void testConfigurableModuleVarDeclNegative() {
BAssertUtil.validateError(result, i++, "configurable variable currently not supported for " +
"'(table<map<()>> & readonly)'\n\t" +
"map constraint type '()' is not supported", 106, 1);

BAssertUtil.validateError(result, i++, "redeclared symbol 'host'", 110, 18);
Assert.assertEquals(result.getErrorCount(), i);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ configurable string? nilUnion = ?;
configurable map<()> nilMap = ?;
configurable Person6 nilRecord1 = ?;
configurable table<map<()>> nilTable = ?;

// Redeclared configurable variable
configurable string host = ?;
configurable int host = ?;

0 comments on commit 4c27c5c

Please sign in to comment.