MarisaKirisame commented on a change in pull request #5780:
URL: https://github.com/apache/incubator-tvm/pull/5780#discussion_r441162964



##########
File path: src/relay/analysis/well_formed.cc
##########
@@ -74,12 +74,21 @@ class WellFormedChecker : private ExprVisitor, 
PatternVisitor {
   }
 
   void VisitExpr_(const LetNode* l) final {
-    Scope s(this);
-    // we do letrec only for FunctionNode,
-    // but shadowing let in let binding is likely programming error, and we 
should forbidden it.
-    Bound(l->var);
-    CheckWellFormed(l->value);
-    CheckWellFormed(l->body);
+    std::vector<Scope*> scopes;
+    Expr let = GetRef<Let>(l);
+    while (auto let_node = let.as<LetNode>()) {
+      scopes.push_back(new Scope(this));
+      // we do letrec only for FunctionNode,
+      // but shadowing let in let binding is likely programming error, and we 
should forbidden it.
+      Bound(let_node->var);
+      CheckWellFormed(let_node->value);
+      let = let_node->body;
+    }
+    CheckWellFormed(let);
+    while (!scopes.empty()) {
+      delete scopes.back();

Review comment:
       can you use unique_ptr?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to