diff --git a/build/examples/_polymorphism.core b/build/examples/_polymorphism.core index 40b58ba..1c879f9 100644 --- a/build/examples/_polymorphism.core +++ b/build/examples/_polymorphism.core @@ -50,7 +50,7 @@ MakeArray :: (a: *int, count: int): Array(int) MultipleArgs :: (): Tuple(int, F32) return {32, 32} -PolyLambda :: ($T: Type): T +PolyLambda :: ($T: Type = *int): T return 32 GetCount :: (a: int): int @@ -71,7 +71,10 @@ main :: (argc: int, argv: **char): int fifth: Array(F32) sixth: Array(Array(F32)) seventh: Variant(int, F32, S64) - // d: int(32) + + test_a := int + test := *int + Assert(test_a != test) // c := MakeArray(buff, GetCount(GetCount(32))) @@ -85,6 +88,6 @@ main :: (argc: int, argv: **char): int Test(10, b = 10, c = 20) Test(a = 10, b = 10, c = 20) - value := PolyLambda(int) + value := PolyLambda(**int) return 0 \ No newline at end of file diff --git a/core_polymorph.cpp b/core_polymorph.cpp index b6adf48..899a3a2 100644 --- a/core_polymorph.cpp +++ b/core_polymorph.cpp @@ -260,7 +260,7 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope, Array *replace, Arr dst->args.init(pctx->perm, src->args.len); For(src->args) { - if (it->flags & AST_POLYMORPH) continue; + if (it->flags & AST_IDENT_POLYMORPH) continue; auto copy = (Ast_Decl *)ast_copy(it, parent_scope, replace, with); dst->args.add(copy); } diff --git a/core_typechecking.cpp b/core_typechecking.cpp index eb8a0b7..1048db5 100644 --- a/core_typechecking.cpp +++ b/core_typechecking.cpp @@ -1408,11 +1408,12 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str return operand_lvalue_set_flag_on_node(node->resolved_type, node); } else if (value.type->kind == TYPE_TYPE) { + value.type_val = type_pointer(value.type_val); if (!is_flag_set(flags, RESOLVE_TYPESPEC)) { - rewrite_into_const(node, Ast_Array, value.value); + rewrite_into_const(node, Ast_Unary, value.value); } - node->resolved_type = type_pointer(value.type_val); + node->resolved_type = value.type_val; return operand_type(node->resolved_type); } else {