From 24fb8d288f45fd3e7710e2305e7abb8c85b1d401 Mon Sep 17 00:00:00 2001 From: Nathan Braswell Date: Mon, 1 Feb 2016 15:59:41 -0500 Subject: [PATCH] Fix templated types getting their indirection stripped off when used --- stdlib/ast_transformation.krak | 2 +- stdlib/type.krak | 1 + tests/to_parse.krak | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/stdlib/ast_transformation.krak b/stdlib/ast_transformation.krak index c0ea824..7a32eed 100644 --- a/stdlib/ast_transformation.krak +++ b/stdlib/ast_transformation.krak @@ -193,7 +193,7 @@ fun transform_type(node: *tree, scope: *ast_node, template_replacements: println(type_syntax_str + " *************************") if (template_replacements.contains_key(type_syntax_str)) { print("Is in template_replacements, returning: ") - var to_ret = template_replacements[type_syntax_str]->clone_with_indirection(indirection) + var to_ret = template_replacements[type_syntax_str]->clone_with_increased_indirection(indirection) println(to_ret->to_string()) return to_ret } diff --git a/stdlib/type.krak b/stdlib/type.krak index 3b9caea..f2a2d33 100644 --- a/stdlib/type.krak +++ b/stdlib/type.krak @@ -138,6 +138,7 @@ obj type (Object) { return string("impossible type, indirection:") + indirection } fun clone_with_increased_indirection(): *type return clone_with_indirection(indirection+1); + fun clone_with_increased_indirection(more: int): *type return clone_with_indirection(indirection+more); fun clone_with_decreased_indirection(): *type return clone_with_indirection(indirection-1); fun clone_with_indirection(ind: int): *type { var to_ret = new() diff --git a/tests/to_parse.krak b/tests/to_parse.krak index 4fdaa5f..2aab4f8 100644 --- a/tests/to_parse.krak +++ b/tests/to_parse.krak @@ -45,8 +45,11 @@ fun some_other_function(in: bool): float { } */ fun main(): int { - var a = id(7) - simple_println(a) + /*var a = id(7)*/ + /*simple_println(a)*/ + /*var b = id<*char>("Double down time")*/ + /*simple_println(b)*/ + simple_println(id<*char>("Double down time"))