You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/06/16 22:14:58 UTC

[GitHub] [incubator-tvm] MarisaKirisame commented on a change in pull request #5780: [Fix] Fix recursive let for well formed check

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:
users@infra.apache.org