slyubomirsky commented on code in PR #15140:
URL: https://github.com/apache/tvm/pull/15140#discussion_r1240334447


##########
src/script/printer/utils.h:
##########
@@ -161,13 +161,25 @@ inline Optional<String> FindFunctionName(const 
IRDocsifier& d, const BaseFunc& f
 }
 
 inline String GenerateUniqueName(std::string name_hint,
-                                 const std::unordered_set<String>& 
defined_names) {
+                                 const std::unordered_set<String>& 
defined_names,
+                                 const Array<String>& binding_names) {
   for (char& c : name_hint) {
     if (c != '_' && !std::isalnum(c)) {
       c = '_';
     }
   }
   std::string name = name_hint;
+  // if the name matches the name currently being bound, then do not add a 
suffix
+  // (this comes up in the case of defining a local function: the local 
function
+  // is the RHS of a binding. The var name on the LHS will have been looked at 
first;
+  // without this check, we would print a suffix on the function name even 
though it
+  // is actually the first definition)
+  for (const auto& bound_name : binding_names) {
+    if (name == bound_name) {
+      return name;
+    }
+  }
+

Review Comment:
   Found a better alternative solution



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to