Skip to content

Commit

Permalink
Fix pretty printer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jroesch authored and icemelon committed Jun 9, 2020
1 parent ed70193 commit c45b9de
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/printer/relay_text_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,19 @@ Doc RelayTextPrinter::VisitExpr_(const IfNode* op) {

Doc RelayTextPrinter::VisitExpr_(const LetNode* op) {
Doc doc;
doc << "let " << AllocVar(op->var) << " = " << Print(op->value, false, true) << ";"
<< Doc::NewLine();
Expr let = GetRef<Let>(op);
while (auto let_node = let.as<LetNode>()) {
doc << "let "
<< AllocVar(let_node->var)
<< " = "
<< Print(let_node->value, false, true)
<< ";"
<< Doc::NewLine();
let = let_node->body;
}
// we use a scope here so GNF hoisting doesn't escape too far
// and nested, unique lets are not hoisted
doc << PrintScope(op->body);
doc << PrintScope(let);
return doc;
}

Expand Down

0 comments on commit c45b9de

Please sign in to comment.