Commit 3c70b0d0 by 雾雨魔理沙 Committed by Tianqi Chen

fix (#2674)

parent e35666ae
...@@ -217,20 +217,20 @@ class AlphaEqualHandler: ...@@ -217,20 +217,20 @@ class AlphaEqualHandler:
return false; return false;
} }
bool VisitType_(const GlobalTypeVarNode* op, const Type& t2) final { bool VisitType_(const GlobalTypeVarNode* lhs, const Type& other) final {
return GetRef<Type>(op) == t2; return GetRef<Type>(lhs) == other;
} }
bool VisitType_(const TypeCallNode* op, const Type& t2) final { bool VisitType_(const TypeCallNode* lhs, const Type& other) final {
const TypeCallNode* pt = t2.as<TypeCallNode>(); const TypeCallNode* rhs = other.as<TypeCallNode>();
if (pt == nullptr if (rhs == nullptr
|| op->args.size() != pt->args.size() || lhs->args.size() != rhs->args.size()
|| !TypeEqual(op->func, pt->func)) { || !TypeEqual(lhs->func, rhs->func)) {
return false; return false;
} }
for (size_t i = 0; i < op->args.size(); ++i) { for (size_t i = 0; i < lhs->args.size(); ++i) {
if (!TypeEqual(op->args[i], pt->args[i])) { if (!TypeEqual(lhs->args[i], rhs->args[i])) {
return false; return false;
} }
} }
...@@ -369,8 +369,8 @@ class AlphaEqualHandler: ...@@ -369,8 +369,8 @@ class AlphaEqualHandler:
} }
} }
bool VisitExpr_(const OpNode* op, const Expr& other) final { bool VisitExpr_(const OpNode* lhs, const Expr& other) final {
return op == other.get(); return lhs == other.get();
} }
bool VisitExpr_(const ConstantNode* lhs, const Expr& other) final { bool VisitExpr_(const ConstantNode* lhs, const Expr& other) final {
...@@ -389,80 +389,80 @@ class AlphaEqualHandler: ...@@ -389,80 +389,80 @@ class AlphaEqualHandler:
} }
} }
bool VisitExpr_(const RefCreateNode* op, const Expr& e2) final { bool VisitExpr_(const RefCreateNode* lhs, const Expr& other) final {
if (const RefCreateNode* nr = e2.as<RefCreateNode>()) { if (const RefCreateNode* rhs = other.as<RefCreateNode>()) {
return ExprEqual(op->value, nr->value); return ExprEqual(lhs->value, rhs->value);
} else { } else {
return false; return false;
} }
} }
bool VisitExpr_(const RefReadNode* op, const Expr& e2) final { bool VisitExpr_(const RefReadNode* lhs, const Expr& other) final {
if (const RefReadNode* r = e2.as<RefReadNode>()) { if (const RefReadNode* rhs = other.as<RefReadNode>()) {
return ExprEqual(op->ref, r->ref); return ExprEqual(lhs->ref, rhs->ref);
} else { } else {
return false; return false;
} }
} }
bool VisitExpr_(const RefWriteNode* op, const Expr& e2) final { bool VisitExpr_(const RefWriteNode* lhs, const Expr& other) final {
if (const RefWriteNode* r = e2.as<RefWriteNode>()) { if (const RefWriteNode* rhs = other.as<RefWriteNode>()) {
return ExprEqual(op->ref, r->ref) && ExprEqual(op->value, r->value); return ExprEqual(lhs->ref, rhs->ref) && ExprEqual(lhs->value, rhs->value);
} else { } else {
return false; return false;
} }
} }
bool VisitExpr_(const ConstructorNode* op, const Expr& e2) final { bool VisitExpr_(const ConstructorNode* lhs, const Expr& other) final {
return GetRef<Expr>(op) == e2; return GetRef<Expr>(lhs) == other;
} }
bool ClauseEqual(const Clause& l, const Clause& r) { bool ClauseEqual(const Clause& lhs, const Clause& rhs) {
return PatternEqual(l->lhs, r->lhs) && ExprEqual(l->rhs, r->rhs); return PatternEqual(lhs->lhs, rhs->lhs) && ExprEqual(lhs->rhs, rhs->rhs);
} }
bool PatternEqual(const Pattern& l, const Pattern& r) { bool PatternEqual(const Pattern& lhs, const Pattern& rhs) {
return VisitPattern(l, r); return VisitPattern(lhs, rhs);
} }
bool VisitPattern_(const PatternWildcardNode* op, const Pattern& r) final { bool VisitPattern_(const PatternWildcardNode* lhs, const Pattern& other) final {
return r.as<PatternWildcardNode>(); return other.as<PatternWildcardNode>();
} }
bool VisitPattern_(const PatternVarNode* op, const Pattern& e2) final { bool VisitPattern_(const PatternVarNode* lhs, const Pattern& other) final {
if (const auto* r = e2.as<PatternVarNode>()) { if (const auto* rhs = other.as<PatternVarNode>()) {
return MergeVarDecl(op->var, r->var); return MergeVarDecl(lhs->var, rhs->var);
} }
return false; return false;
} }
bool VisitPattern_(const PatternConstructorNode* op, const Pattern& e2) final { bool VisitPattern_(const PatternConstructorNode* lhs, const Pattern& other) final {
const auto* r = e2.as<PatternConstructorNode>(); const auto* rhs = other.as<PatternConstructorNode>();
if (r == nullptr if (rhs == nullptr
|| !ExprEqual(op->constructor, r->constructor) || !ExprEqual(lhs->constructor, rhs->constructor)
|| op->patterns.size() != r->patterns.size()) { || lhs->patterns.size() != rhs->patterns.size()) {
return false; return false;
} }
for (size_t i = 0; i < op->patterns.size(); i++) { for (size_t i = 0; i < lhs->patterns.size(); i++) {
if (!PatternEqual(op->patterns[i], r->patterns[i])) { if (!PatternEqual(lhs->patterns[i], rhs->patterns[i])) {
return false; return false;
} }
} }
return true; return true;
} }
bool VisitExpr_(const MatchNode* op, const Expr& e2) final { bool VisitExpr_(const MatchNode* lhs, const Expr& other) final {
const MatchNode* r = e2.as<MatchNode>(); const MatchNode* rhs = other.as<MatchNode>();
if (r == nullptr if (rhs == nullptr
|| !ExprEqual(op->data, r->data) || !ExprEqual(lhs->data, rhs->data)
|| op->clauses.size() != r->clauses.size()) { || lhs->clauses.size() != rhs->clauses.size()) {
return false; return false;
} }
for (size_t i = 0; i < op->clauses.size(); ++i) { for (size_t i = 0; i < lhs->clauses.size(); ++i) {
if (!ClauseEqual(op->clauses[i], r->clauses[i])) { if (!ClauseEqual(lhs->clauses[i], rhs->clauses[i])) {
return false; return false;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment