Skip to content

Commit

Permalink
Check type of simple assignment expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Lai-YT committed Sep 14, 2023
1 parent 16f06da commit adc04c9
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,23 @@ void SimpleAssignmentExprNode::Dump(int pad) const {
<< std::endl;
}

void SimpleAssignmentExprNode::CheckType(ScopeStack& env) {}
void SimpleAssignmentExprNode::CheckType(ScopeStack& env) {
expr_->CheckType(env);
if (auto symbol = env.LookUp(id_)) {
if (expr_->type == symbol->expr_type) {
// 6.5.16 Assignment operators
// The type of an assignment expression is the type of the left
// operand unless the left operand has qualified type, in which case it is
// the unqualified version of the type of the left operand.
type = symbol->expr_type;
} else {
// TODO: assigning to 'symbol->expr_type' from incompatible type
// 'expr_->type'
}
} else {
// TODO: 'id_' undeclared
}
}

namespace {

Expand Down

0 comments on commit adc04c9

Please sign in to comment.