Skip to content

Commit

Permalink
Fixed error in recent change for checking assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Oct 17, 2024
1 parent 9cec22f commit 9999463
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -650,18 +650,22 @@ private void checkAssignment(Statement current, (Assignable) `( <Assignable arg>

private AType computeAssignmentRhsType(Statement current, AType lhsType, str operator, AType rhsType, Solver s){
checkNonVoid(current, rhsType, s, "Righthand side of assignment");
s.requireComparable(rhsType, lhsType, error(current, "Cannot assign righthand side of type %t to lefthand side of type %t", rhsType, lhsType));
resultType = avalue();
switch(operator){
case "=": return rhsType;
case "+=": return computeAdditionType(current, lhsType, rhsType, s);
case "-=": return computeSubtractionType(current, lhsType, rhsType, s);
case "*=": return computeProductType(current, lhsType, rhsType, s);
case "/=": return computeDivisionType(current, lhsType, rhsType, s);
case "&=": return computeIntersectionType(current, lhsType, rhsType, s);
case "?=": return alub(lhsType, rhsType);
case "=": resultType = rhsType;
case "+=": resultType = computeAdditionType(current, lhsType, rhsType, s);
case "-=": resultType = computeSubtractionType(current, lhsType, rhsType, s);
case "*=": resultType = computeProductType(current, lhsType, rhsType, s);
case "/=": resultType = computeDivisionType(current, lhsType, rhsType, s);
case "&=": resultType = computeIntersectionType(current, lhsType, rhsType, s);
case "?=": resultType = alub(lhsType, rhsType);
default: {
s.report(error(current, "Unsupported operator %s in assignment", operator));
return avalue();
}
}
s.report(error(current, "Unsupported operator %s in assignment", operator));
return avalue();
s.requireComparable(resultType, lhsType, error(current, "Cannot assign righthand side of type %t to lefthand side of type %t", resultType, lhsType));
return resultType;
}

private void checkAssignment(Statement current, (Assignable) `<QualifiedName name>`, str operator, Statement statement, Collector c){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module lang::rascalcore::compile::Examples::Tst4

void main(){
set[str] s = {};
s += "a";
}
// // Stat 4
// real main() {
// n = 1;
Expand Down

0 comments on commit 9999463

Please sign in to comment.