Skip to content

Commit

Permalink
Fix op used when stringifying AstExprIndexName (#572)
Browse files Browse the repository at this point in the history
* Fix op used when stringifying AstExprIndexName

* Remove visualizeWithSelf
  • Loading branch information
JohnnyMorganz committed Jul 5, 2022
1 parent 2460e38 commit 6303ae3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
20 changes: 3 additions & 17 deletions Analysis/src/Transpiler.cpp
Expand Up @@ -205,20 +205,6 @@ struct Printer
}
}

void visualizeWithSelf(AstExpr& expr, bool self)
{
if (!self)
return visualize(expr);

AstExprIndexName* func = expr.as<AstExprIndexName>();
LUAU_ASSERT(func);

visualize(*func->expr);
writer.symbol(":");
advance(func->indexLocation.begin);
writer.identifier(func->index.value);
}

void visualizeTypePackAnnotation(const AstTypePack& annotation, bool forVarArg)
{
advance(annotation.location.begin);
Expand Down Expand Up @@ -366,7 +352,7 @@ struct Printer
}
else if (const auto& a = expr.as<AstExprCall>())
{
visualizeWithSelf(*a->func, a->self);
visualize(*a->func);
writer.symbol("(");

bool first = true;
Expand All @@ -385,7 +371,7 @@ struct Printer
else if (const auto& a = expr.as<AstExprIndexName>())
{
visualize(*a->expr);
writer.symbol(".");
writer.symbol(std::string(1, a->op));
writer.write(a->index.value);
}
else if (const auto& a = expr.as<AstExprIndexExpr>())
Expand Down Expand Up @@ -766,7 +752,7 @@ struct Printer
else if (const auto& a = program.as<AstStatFunction>())
{
writer.keyword("function");
visualizeWithSelf(*a->name, a->func->self != nullptr);
visualize(*a->name);
visualizeFunctionBody(*a->func);
}
else if (const auto& a = program.as<AstStatLocalFunction>())
Expand Down
2 changes: 1 addition & 1 deletion tests/Transpiler.test.cpp
Expand Up @@ -583,7 +583,7 @@ TEST_CASE_FIXTURE(Fixture, "transpile_error_expr")
auto names = AstNameTable{allocator};
ParseResult parseResult = Parser::parse(code.data(), code.size(), names, allocator, {});

CHECK_EQ("local a = (error-expr: f.%error-id%)-(error-expr)", transpileWithTypes(*parseResult.root));
CHECK_EQ("local a = (error-expr: f:%error-id%)-(error-expr)", transpileWithTypes(*parseResult.root));
}

TEST_CASE_FIXTURE(Fixture, "transpile_error_stat")
Expand Down

0 comments on commit 6303ae3

Please sign in to comment.