mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-10 22:00:54 +01:00
Fix op used when stringifying AstExprIndexName (#572)
* Fix op used when stringifying AstExprIndexName * Remove visualizeWithSelf
This commit is contained in:
parent
2460e38998
commit
6303ae30c4
2 changed files with 4 additions and 18 deletions
|
@ -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)
|
void visualizeTypePackAnnotation(const AstTypePack& annotation, bool forVarArg)
|
||||||
{
|
{
|
||||||
advance(annotation.location.begin);
|
advance(annotation.location.begin);
|
||||||
|
@ -366,7 +352,7 @@ struct Printer
|
||||||
}
|
}
|
||||||
else if (const auto& a = expr.as<AstExprCall>())
|
else if (const auto& a = expr.as<AstExprCall>())
|
||||||
{
|
{
|
||||||
visualizeWithSelf(*a->func, a->self);
|
visualize(*a->func);
|
||||||
writer.symbol("(");
|
writer.symbol("(");
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -385,7 +371,7 @@ struct Printer
|
||||||
else if (const auto& a = expr.as<AstExprIndexName>())
|
else if (const auto& a = expr.as<AstExprIndexName>())
|
||||||
{
|
{
|
||||||
visualize(*a->expr);
|
visualize(*a->expr);
|
||||||
writer.symbol(".");
|
writer.symbol(std::string(1, a->op));
|
||||||
writer.write(a->index.value);
|
writer.write(a->index.value);
|
||||||
}
|
}
|
||||||
else if (const auto& a = expr.as<AstExprIndexExpr>())
|
else if (const auto& a = expr.as<AstExprIndexExpr>())
|
||||||
|
@ -766,7 +752,7 @@ struct Printer
|
||||||
else if (const auto& a = program.as<AstStatFunction>())
|
else if (const auto& a = program.as<AstStatFunction>())
|
||||||
{
|
{
|
||||||
writer.keyword("function");
|
writer.keyword("function");
|
||||||
visualizeWithSelf(*a->name, a->func->self != nullptr);
|
visualize(*a->name);
|
||||||
visualizeFunctionBody(*a->func);
|
visualizeFunctionBody(*a->func);
|
||||||
}
|
}
|
||||||
else if (const auto& a = program.as<AstStatLocalFunction>())
|
else if (const auto& a = program.as<AstStatLocalFunction>())
|
||||||
|
|
|
@ -583,7 +583,7 @@ TEST_CASE_FIXTURE(Fixture, "transpile_error_expr")
|
||||||
auto names = AstNameTable{allocator};
|
auto names = AstNameTable{allocator};
|
||||||
ParseResult parseResult = Parser::parse(code.data(), code.size(), names, 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")
|
TEST_CASE_FIXTURE(Fixture, "transpile_error_stat")
|
||||||
|
|
Loading…
Add table
Reference in a new issue