Fix printing function types like (a -> b) -> c

This commit is contained in:
Nikita Lisitsa 2026-03-21 22:02:30 +03:00
parent 7d5795d9bf
commit 357baa9652
3 changed files with 6 additions and 2 deletions

View file

@ -52,7 +52,7 @@ namespace pslang::ast
void apply(function_type const & type) void apply(function_type const & type)
{ {
if (type.arguments.size() == 1) if (type.arguments.size() == 1 && !std::get_if<function_type>(type.arguments[0].get()))
{ {
apply(*type.arguments.front()); apply(*type.arguments.front());
out << " -> "; out << " -> ";

View file

@ -87,7 +87,7 @@ namespace pslang::types
void apply(function_type const & type) void apply(function_type const & type)
{ {
if (type.arguments.size() == 1) if (type.arguments.size() == 1 && !is_function_type(*type.arguments[0]))
{ {
apply(*type.arguments.front()); apply(*type.arguments.front());
out << " -> "; out << " -> ";

View file

@ -40,3 +40,7 @@ General backlog:
* Mutually recursive structs (relevant only with pointers) * Mutually recursive structs (relevant only with pointers)
* Empty array expression * Empty array expression
* Calling functions as methods * Calling functions as methods
* Replace std::runtime_error with appropriate custom exception types
* Replace std::ostringstream with std::format
* TEST COVERAGE!!!
* Separate actual AST from pre-AST (the one before indentation & scoping is resolved)