-
Notifications
You must be signed in to change notification settings - Fork 744
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
Add support for record literals with mapping binding patterns and fix using mapping-binding pattern within a list binding pattern against an open record #40283
Changes from all commits
8ce1f27
0c327e6
facc751
297e16f
26a447f
8339c9d
87fcf93
797ffe3
c870715
872d3aa
3519ace
6b1feaa
03024d3
82e3439
6568a25
cb7e540
08f5e57
82ff635
edebb78
94bf9c0
3de0d3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2199,11 +2199,6 @@ public void visit(BLangSimpleVariableDef varDefNode, AnalyzerData data) { | |
|
||
@Override | ||
public void visit(BLangRecordVariableDef varDefNode, AnalyzerData data) { | ||
// TODO: 10/18/18 Need to support record literals as well | ||
if (varDefNode.var.expr != null && varDefNode.var.expr.getKind() == RECORD_LITERAL_EXPR) { | ||
dlog.error(varDefNode.pos, DiagnosticErrorCode.INVALID_LITERAL_FOR_TYPE, "record binding pattern"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where have the tests been added for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noticed that they've been added in RecordVariableReferenceTest.java. That's not the correct class. Should go in RecordVariableDefinitionTest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack |
||
return; | ||
} | ||
analyzeNode(varDefNode.var, data); | ||
} | ||
|
||
|
@@ -2386,15 +2381,9 @@ public void visit(BLangRecordDestructure recordDeStmt, AnalyzerData data) { | |
setTypeOfVarRef(recordDeStmt.varRef, data); | ||
|
||
SymbolEnv currentEnv = data.env; | ||
typeChecker.checkExpr(recordDeStmt.varRef, currentEnv, symTable.noType, data.prevEnvs, | ||
data.typeChecker.checkExpr(recordDeStmt.varRef, currentEnv, symTable.noType, data.prevEnvs, | ||
data.commonAnalyzerData); | ||
|
||
if (recordDeStmt.expr.getKind() == RECORD_LITERAL_EXPR) { | ||
// TODO: 10/18/18 Need to support record literals as well | ||
dlog.error(recordDeStmt.expr.pos, DiagnosticErrorCode.INVALID_RECORD_LITERAL_BINDING_PATTERN); | ||
dulajdilshan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return; | ||
} | ||
typeChecker.checkExpr(recordDeStmt.expr, currentEnv, symTable.noType, data.prevEnvs, | ||
data.typeChecker.checkExpr(recordDeStmt.expr, currentEnv, symTable.noType, data.prevEnvs, | ||
data.commonAnalyzerData); | ||
checkRecordVarRefEquivalency(recordDeStmt.pos, recordDeStmt.varRef, recordDeStmt.expr.getBType(), | ||
recordDeStmt.expr.pos, data); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,66 +248,64 @@ public void testNegativeCases() { | |
65, 33); | ||
BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected '[int,int]', found '[int...]'", | ||
70, 36); | ||
BAssertUtil.validateError(negativeResult, i++, "record literal is not supported for record binding pattern", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wasn't this test removed from the bal file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's removed. |
||
79, 32); | ||
BAssertUtil.validateError(negativeResult, i++, "invalid operation: type " + | ||
"'seq record {| string name; int price1; |}' does not support field access", 87, 29); | ||
"'seq record {| string name; int price1; |}' does not support field access", 78, 29); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 87, 29); | ||
"list constructor or function invocation", 78, 29); | ||
BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'int[]', found 'seq int?'", | ||
108, 32); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'int'", 116, 40); | ||
99, 32); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'int'", 107, 40); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element" + | ||
" list constructor or function invocation", 116, 40); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'int'", 120, 33); | ||
" list constructor or function invocation", 107, 40); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'int'", 111, 33); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element" + | ||
" list constructor or function invocation", 120, 33); | ||
" list constructor or function invocation", 111, 33); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'seq int'", | ||
133, 36); | ||
124, 36); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 133, 36); | ||
"list constructor or function invocation", 124, 36); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 133, 45); | ||
"list constructor or function invocation", 124, 45); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'seq int'", | ||
136, 28); | ||
127, 28); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 136, 28); | ||
"list constructor or function invocation", 127, 28); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 136, 37); | ||
"list constructor or function invocation", 127, 37); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'seq int'", | ||
139, 28); | ||
130, 28); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 139, 28); | ||
"list constructor or function invocation", 130, 28); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 139, 37); | ||
"list constructor or function invocation", 130, 37); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'seq int'", | ||
142, 28); | ||
133, 28); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 142, 28); | ||
"list constructor or function invocation", 133, 28); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 142, 37); | ||
"list constructor or function invocation", 133, 37); | ||
BAssertUtil.validateError(negativeResult, i++, "operator '+' not defined for 'seq int' and 'seq int'", | ||
145, 26); | ||
136, 26); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 145, 26); | ||
"list constructor or function invocation", 136, 26); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 145, 35); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after seq argument", 148, 36); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after rest argument", 151, 39); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after seq argument", 154, 37); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after seq argument", 154, 40); | ||
"list constructor or function invocation", 136, 35); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after seq argument", 139, 36); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after rest argument", 142, 39); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after seq argument", 145, 37); | ||
BAssertUtil.validateError(negativeResult, i++, "arguments not allowed after seq argument", 145, 40); | ||
BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected '(any|error)[]', found 'int'", | ||
157, 37); | ||
148, 37); | ||
BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected " + | ||
"'([int,int...]|record {| int n; |})', found '[int...]'", 167, 43); | ||
"'([int,int...]|record {| int n; |})', found '[int...]'", 158, 43); | ||
BAssertUtil.validateError(negativeResult, i++, "invalid grouping key type 'error', expected a subtype of " + | ||
"'anydata'", 175, 26); | ||
"'anydata'", 166, 26); | ||
BAssertUtil.validateError(negativeResult, i++, "invalid grouping key type 'error', expected a subtype of " + | ||
"'anydata'", 178, 26); | ||
"'anydata'", 169, 26); | ||
BAssertUtil.validateError(negativeResult, i++, "incompatible types: expected 'string', found 'seq string'", | ||
200, 24); | ||
191, 24); | ||
BAssertUtil.validateError(negativeResult, i++, "sequence variable can be used in a single element " + | ||
"list constructor or function invocation", 200, 24); | ||
"list constructor or function invocation", 191, 24); | ||
Assert.assertEquals(negativeResult.getErrorCount(), i); | ||
} | ||
|
||
|
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.
Why isn't this DiagnosticErrorCode removed?
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.
Removed via 08f5e57c