From c1dec6a0d198723b8edefea12a2d01bec92a81ed Mon Sep 17 00:00:00 2001 From: ProgramSnail Date: Sun, 7 May 2023 09:25:38 +0300 Subject: [PATCH] type_check_visitor fixes, array access and function call syntax change --- include/type_info_contexts.hpp | 4 + src/.type_check_visitor.cpp.kate-swp | Bin 0 -> 173 bytes src/build_visitor.cpp | 2 +- src/print_visitor.cpp | 19 +- src/type_check_visitor.cpp | 91 +++++- tests/arrays.lang | 20 +- tests/flow_control.lang | 16 +- tests/functions.lang | 34 +- tests/lambdas.lang | 4 +- tests/match.lang | 460 ++++++++++++++------------- tests/memory.lang | 4 +- tests/tuples.lang | 5 +- tests/type_casting.lang | 4 +- tests/typeclasses.lang | 4 +- tests/types.lang | 68 ++-- tests/variants.lang | 2 +- 16 files changed, 426 insertions(+), 311 deletions(-) create mode 100644 src/.type_check_visitor.cpp.kate-swp diff --git a/include/type_info_contexts.hpp b/include/type_info_contexts.hpp index 99faacb..7652f0e 100644 --- a/include/type_info_contexts.hpp +++ b/include/type_info_contexts.hpp @@ -124,6 +124,10 @@ private: Context() = default; bool DefineVariable(const std::string& name, utils::IdType type_id) { + if (name == "_") { // placeholder // TODO: check in all places + return true; + } + if (variables_.count(name) > 0) { return false; } diff --git a/src/.type_check_visitor.cpp.kate-swp b/src/.type_check_visitor.cpp.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..61da736694592d6fc89d9682b6ca1d801bf57af1 GIT binary patch literal 173 zcmZQzU=Z?7EJ;-eE>A2_aLdd|RWQ;sU|?Vn*)Mk0`t%3WKTjWQ4c!*_bf&nO#fji> z1_q{Tpe%!HuqTjN17ZRJqrPh}LWB`Rgb5^~fKb5<;)fvkEFiu=g3k)#yCC>%5P1M^ C3Lh>2 literal 0 HcmV?d00001 diff --git a/src/build_visitor.cpp b/src/build_visitor.cpp index ae5526c..7e7353b 100644 --- a/src/build_visitor.cpp +++ b/src/build_visitor.cpp @@ -985,7 +985,7 @@ void BuildVisitor::Visit(FunctionCallExpression* node) { size_t child_count = parse_node.NamedChildCount(); - if (child_count > excluded_child_count) { // always true (repeat1) + if (child_count > excluded_child_count) { bool parameters_ended = false; node->arguments.resize(child_count - excluded_child_count); diff --git a/src/print_visitor.cpp b/src/print_visitor.cpp index e39c54e..20ed2ea 100644 --- a/src/print_visitor.cpp +++ b/src/print_visitor.cpp @@ -421,7 +421,7 @@ void PrintVisitor::Visit(ReferenceExpression* node) { void PrintVisitor::Visit(AccessExpression* node) { out_ << "[AccessExpression] ("; Visit(node->name.get()); - out_ << ") : ("; + out_ << ") ` ("; Visitor::Visit(node->id); out_ << ')'; } @@ -447,15 +447,26 @@ void PrintVisitor::Visit(FunctionCallExpression* node) { out_ << "] ("; + bool is_first = true; for (auto& parameter : node->parameters) { + if (!is_first) { + out_ << ", "; + } + is_first = false; + Visit(parameter.get()); - out_ << ", "; } - out_ << ") ("; + out_ << ") : ("; + + is_first = true; for (auto& argument : node->arguments) { + if (!is_first) { + out_ << ", "; + } + is_first = false; + Visitor::Visit(argument); - out_ << ", "; } out_ << ")"; } diff --git a/src/type_check_visitor.cpp b/src/type_check_visitor.cpp index 1e84edf..bf16d53 100644 --- a/src/type_check_visitor.cpp +++ b/src/type_check_visitor.cpp @@ -524,12 +524,85 @@ void TypeCheckVisitor::Visit(LoopControlExpression& node) { // enum // Operators +// TODO void TypeCheckVisitor::Visit(BinaryOperatorExpression* node) { // TODO: Check, that type is not abstract ?? auto maybe_operator_id = namespace_visitor_.FindFunction(std::nullopt, node->operator_name); + if (maybe_operator_id.has_value()) { + const info::definition::Function& operator_info = namespace_visitor_.GetGlobalInfo()->GetFunctionInfo(maybe_operator_id.value()); + + if (!operator_info.declaration.has_value()) { + error_handling::HandleTypecheckError("Operator declaration not found", node->base); + } + + if (!operator_info.definition.has_value()) { // TODO: builtin, etc. + error_handling::HandleTypecheckError("Operator definition not found", node->base); + } + + if (operator_info.argument_count != 3) { // 2 + return type + error_handling::HandleTypecheckError("Operator wrong argument count", node->base); + } + + if (operator_info.declaration->parameters.size() > 0) { + error_handling::HandleTypecheckError("Operator with parameters", node->base); + } + + Visitor::Visit(*operator_info.declaration.value().argument_types[0]); + utils::IdType left_expression_type = current_type_; // TODO: type in context of deduced types + + Visitor::Visit(node->left_expression); + if (!context_manager_.AddTypeRequirement(current_type_, left_expression_type)) { + error_handling::HandleTypecheckError("Operator left expression has wrong type", node->base); + } + + Visitor::Visit(*operator_info.declaration.value().argument_types[1]); + utils::IdType right_expression_type = current_type_; // TODO: type in context of deduced types + + Visitor::Visit(node->right_expression); + if (!context_manager_.AddTypeRequirement(current_type_, right_expression_type)) { + error_handling::HandleTypecheckError("Operator right expression has wrong type", node->base); + } + + Visitor::Visit(*operator_info.declaration.value().argument_types.back()); + return; + } + + Visitor::Visit(node->left_expression); + auto maybe_left_type = context_manager_.GetType(current_type_); + + utils::ValueType left_value_type = context_manager_.GetValueType(current_type_); + + if (!maybe_left_type.has_value()) { + error_handling::HandleTypecheckError("Operator not found (type is not DefinedType)", node->base); + } + + auto maybe_left_type_info = namespace_visitor_.GetGlobalInfo()->GetTypeInfo(maybe_left_type.value()->GetTypeId()); + + std::string left_type_name = maybe_left_type_info.value().type.type; + + auto maybe_const_operator_id = namespace_visitor_.FindMethod(std::nullopt, + left_type_name, + node->operator_name, + utils::IsConstModifier::Const); + + if (left_value_type != utils::ValueType::Const) { + maybe_operator_id = namespace_visitor_.FindMethod(std::nullopt, + left_type_name, + node->operator_name, + utils::IsConstModifier::Var); + } + + if (!maybe_operator_id.has_value() && !maybe_const_operator_id.has_value()) { + error_handling::HandleTypecheckError("Operator not found (method name not found)", node->base); + } + + if (maybe_operator_id.has_value() && maybe_const_operator_id.has_value()) { + error_handling::HandleTypecheckError("Ambigious operator (const and var method)", node->base); + } + if (!maybe_operator_id.has_value()) { - error_handling::HandleTypecheckError("Operator not found", node->base); + maybe_operator_id = maybe_const_operator_id; } const info::definition::Function& operator_info = namespace_visitor_.GetGlobalInfo()->GetFunctionInfo(maybe_operator_id.value()); @@ -542,7 +615,7 @@ void TypeCheckVisitor::Visit(BinaryOperatorExpression* node) { error_handling::HandleTypecheckError("Operator definition not found", node->base); } - if (operator_info.argument_count != 2) { + if (operator_info.argument_count != 2) { // argument + return type error_handling::HandleTypecheckError("Operator wrong argument count", node->base); } @@ -550,21 +623,15 @@ void TypeCheckVisitor::Visit(BinaryOperatorExpression* node) { error_handling::HandleTypecheckError("Operator with parameters", node->base); } - Visitor::Visit(*operator_info.declaration.value().argument_types[0]); - utils::IdType left_expression_type = current_type_; // TODO: type in context of deduced types - - Visitor::Visit(node->left_expression); - if (!context_manager_.AddTypeRequirement(current_type_, left_expression_type)) { - error_handling::HandleTypecheckError("Operator left expression has wrong type", node->base); - } - - Visitor::Visit(*operator_info.declaration.value().argument_types[1]); + Visitor::Visit(*operator_info.declaration.value().argument_types[9]); utils::IdType right_expression_type = current_type_; // TODO: type in context of deduced types Visitor::Visit(node->right_expression); if (!context_manager_.AddTypeRequirement(current_type_, right_expression_type)) { error_handling::HandleTypecheckError("Operator right expression has wrong type", node->base); } + + Visitor::Visit(*operator_info.declaration.value().argument_types.back()); } void TypeCheckVisitor::Visit(UnaryOperatorExpression* node) { @@ -748,7 +815,7 @@ void TypeCheckVisitor::Visit(FunctionCallExpression* node) { context_manager_.AddTypeRequirement(current_type_, argument_type); } - Visitor::Visit(*function_declaration.argument_types.back()); // add return type to info ?? + Visitor::Visit(*function_declaration.argument_types.back()); current_type_ = TypeInContext(current_type_, context); } diff --git a/tests/arrays.lang b/tests/arrays.lang index 1a76d8b..8fce315 100644 --- a/tests/arrays.lang +++ b/tests/arrays.lang @@ -1,21 +1,21 @@ decl test_arrays : Unit -> Unit def test_arrays = { var arr1 = ,1 ,2 ,3 - const arr2 = Int._array 32 - var arr3 = String._array 11 + const arr2 = Int._array: 32 + var arr3 = String._array: 11 const arr4 = 'a'..'z' const n = 100 - var @arr5 <- Int.@_new_array 10 + var @arr5 <- Int.@_new_array: 10 - var @arr6 <- String.@_new_array 10 + var @arr6 <- String.@_new_array: 10 var ~arr6_reference = ~arr6 - const elem1 = arr1:0 - var elem2 = arr1:2 - const ~ref1 = ~arr1:1 - var ~ref2 = ~arr1:3 - ; arr1:1 = 123 + const elem1 = arr1`0 + var elem2 = arr1`2 + const ~ref1 = ~arr1`1 + var ~ref2 = ~arr1`3 + ; arr1`1 = 123 - ; ref1 = arr1:2 // set value + ; ref1 = arr1`2 // set value ; ~ref1 = ~ref2 // set reference } diff --git a/tests/flow_control.lang b/tests/flow_control.lang index 4f7bae9..160f8c3 100644 --- a/tests/flow_control.lang +++ b/tests/flow_control.lang @@ -1,29 +1,29 @@ decl flow_control_test : Unit -> Unit def flow_control_test = { - if ((a < b) || (a == b)) && (b < c) then IO.print x + if ((a < b) || (a == b)) && (b < c) then IO.print: x elif x < 0 then { ; ++x - ; IO.print y + ; IO.print: y } else { return {} } - while (a > 0) && (!array.is_empty ()) do { + while (a > 0) && (!array.is_empty:) do { ; --a - ; array->pop + ; array.pop: } while x < 10 do x += x + 3 for i in 0..y do { - ; IO.print i + ; IO.print: i } for & i & j in (& 0..y & 0..k) do { - ; IO.print 1 - ; IO.print 2 - ; IO.print 128 + ; IO.print: 1 + ; IO.print: 2 + ; IO.print: 128 } loop { diff --git a/tests/functions.lang b/tests/functions.lang index fa235ef..0f33512 100644 --- a/tests/functions.lang +++ b/tests/functions.lang @@ -5,24 +5,24 @@ decl fib : Int -> Int def fib : n = match n with | 0 | 1 -> 1 - | n ? n > 1 -> fib (n - 1) + fib n - | _ -> error "n must be positive" + | n ? n > 1 -> fib: (n - 1) + fib: n + | _ -> error: "n must be positive" decl fact : Int -> Int def fact : n = match n with | 0 -> 1 - | n ? n > 0 -> n * fact (n - 1) - | _ -> error "n must be positive" + | n ? n > 0 -> n * fact: (n - 1) + | _ -> error: "n must be positive" decl find_prefix_hashes ('H : (#AccHash Char)) : String -> (Array 'H) def find_prefix_hashes : str = { - var hashes = (Array 'H).new (str.size () + 1) + var hashes = (Array 'H).new: (str.size: + 1) - ; hashes:0 = 'H.of str:0 - for i in 1..hashes.size () do { - ; hashes:i = hashes:(i - 1) - ; hashes:i.append str:i + ; hashes`0 = 'H.of: str`0 + for i in 1..hashes.size: do { + ; hashes`i = hashes`(i - 1) + ; hashes`i.append: str`i } return hashes @@ -32,16 +32,16 @@ alias Hash = (AccHash Char) decl find_substring : String -> String -> (Array Index) def find_substring : str substr = { - var result = (Array Index).empty () + var result = (Array Index).empty: - const str_hashes = find_prefix_hashes Hash str - const substr_hash = Hash.of substr + const str_hashes = find_prefix_hashes Hash: str + const substr_hash = Hash.of: substr - for i in 0..(str_hashes.size () - substr.size ()) do { - const part_hash = Hash.diff str_hashes(i + substr->size ()) str_hashes:i + for i in 0..(str_hashes.size: - substr.size:) do { + const part_hash = Hash.diff: str_hashes`(i + substr->size:) str_hashes`i if part_hash == substr_hash then { - ; result.push i + ; result.push: i } } @@ -53,10 +53,10 @@ def is_empty = 0 decl do_something : Unit -> Unit def do_something = - IO.print "Hello World!" + IO.print: "Hello World!" decl mul : Int -> Int -> Int def mul : x y = x * y decl mul_10 : Int -> Int -def mul_10 = mul 10 +def mul_10 = mul: 10 diff --git a/tests/lambdas.lang b/tests/lambdas.lang index fbec159..e58bd96 100644 --- a/tests/lambdas.lang +++ b/tests/lambdas.lang @@ -1,11 +1,11 @@ decl test_lambdas : Unit -> Unit def test_lambdas = { const lambda1 = \x -> x * x - const lambda2 = \x -> x.hash () + const lambda2 = \x -> x.hash: const lambda3 = \x y -> x + y const lambda4 = \x -> { - ; IO.print x + ; IO.print: x const y = x + x return y } diff --git a/tests/match.lang b/tests/match.lang index 00719f0..c6af2ff 100644 --- a/tests/match.lang +++ b/tests/match.lang @@ -2,18 +2,20 @@ Match ================================================================================ +decl fruit_cost : Fruit -> Int def fruit_cost : fruit = { return (match fruit with | $Banana -> 11 | $Apple | $Orange -> 7) } +decl amount_to_string : Int -> Bool -> String def amount_to_string : x is_zero_separated = { const ans = match x with - | 0 ? is_zero_separated () -> "Zero" + | 0 ? is_zero_separated -> "Zero" | 0 | 1 | 2 | 3 | 4 -> "Few" - | x ? (5..9).contains x -> "Several" - | x ? (10..19).contains x -> "Pack" + | x ? (5..9).contains: x -> "Several" + | x ? (10..19).contains: x -> "Pack" | _ -> "Lots" return ans } @@ -22,223 +24,247 @@ def amount_to_string : x is_zero_separated = { (source_file (source_statement - (function_definition_statement - (function_definition - (extended_name - (name_identifier)) - (extended_name - (name_identifier))) - (superexpression - (expression - (prefixed_expression - (block - (block_statement - (prefixed_expression - (return_expression - (expression - (subexpression - (subexpression_token - (scoped_statement - (superexpression - (flow_control - (match - (expression - (subexpression - (subexpression_token - (name_expression - (extended_name - (name_identifier)))))) - (match_case - (pattern - (type_constructor_pattern - (type_expression - (type_subexpression - (type_identifier))))) - (expression - (subexpression - (subexpression_token - (literal - (number_literal)))))) - (match_case - (pattern - (type_constructor_pattern - (type_expression - (type_subexpression - (type_identifier)))))) - (match_case - (pattern - (type_constructor_pattern - (type_expression - (type_subexpression - (type_identifier))))) - (expression - (subexpression - (subexpression_token - (literal - (number_literal)))))))))))))))))))))) + (partition_statement + (namespace_statement + (function_declaration + (extended_name + (name_identifier)) + (function_type + (scoped_any_type + (type_expression + (parametrized_type + (type_identifier)))) + (scoped_any_type + (type_expression + (parametrized_type + (type_identifier))))))))) (source_statement - (function_definition_statement - (function_definition - (extended_name - (name_identifier)) - (extended_name - (name_identifier)) - (extended_name - (name_identifier))) - (superexpression - (expression - (prefixed_expression - (block - (block_statement - (variable_definition_statement - (any_name - (annotated_name - (extended_name - (name_identifier)))) - (superexpression - (flow_control - (match + (partition_statement + (namespace_statement + (function_definition_statement + (function_definition + (extended_name + (name_identifier)) + (extended_name + (name_identifier))) + (superexpression + (expression + (prefixed_expression + (block + (block_statement + (prefixed_expression + (return_expression + (expression + (subexpression + (subexpression_token + (scoped_statement + (superexpression + (flow_control + (match + (expression + (subexpression + (subexpression_token + (name_expression + (extended_name + (name_identifier)))))) + (match_case + (pattern + (type_constructor_pattern + (type_expression + (parametrized_type + (type_identifier))))) + (expression + (subexpression + (subexpression_token + (literal + (number_literal)))))) + (match_case + (pattern + (type_constructor_pattern + (type_expression + (parametrized_type + (type_identifier)))))) + (match_case + (pattern + (type_constructor_pattern + (type_expression + (parametrized_type + (type_identifier))))) + (expression + (subexpression + (subexpression_token + (literal + (number_literal)))))))))))))))))))))))) + (source_statement + (partition_statement + (namespace_statement + (function_declaration + (extended_name + (name_identifier)) + (function_type + (scoped_any_type + (type_expression + (parametrized_type + (type_identifier)))) + (scoped_any_type + (type_expression + (parametrized_type + (type_identifier)))) + (scoped_any_type + (type_expression + (parametrized_type + (type_identifier))))))))) + (source_statement + (partition_statement + (namespace_statement + (function_definition_statement + (function_definition + (extended_name + (name_identifier)) + (extended_name + (name_identifier)) + (extended_name + (name_identifier))) + (superexpression + (expression + (prefixed_expression + (block + (block_statement + (variable_definition_statement + (any_name + (annotated_name + (extended_name + (name_identifier)))) + (superexpression + (flow_control + (match + (expression + (subexpression + (subexpression_token + (name_expression + (extended_name + (name_identifier)))))) + (match_case + (pattern + (literal + (number_literal))) + (expression + (subexpression + (subexpression_token + (name_expression + (extended_name + (name_identifier)))))) + (expression + (subexpression + (subexpression_token + (literal + (string_literal)))))) + (match_case + (pattern + (literal + (number_literal)))) + (match_case + (pattern + (literal + (number_literal)))) + (match_case + (pattern + (literal + (number_literal)))) + (match_case + (pattern + (literal + (number_literal)))) + (match_case + (pattern + (literal + (number_literal))) + (expression + (subexpression + (subexpression_token + (literal + (string_literal)))))) + (match_case + (pattern + (extended_name + (name_identifier))) + (expression + (subexpression + (function_call_expression + (subexpression_token + (scoped_statement + (superexpression + (expression + (subexpression + (binary_operator_expression + (subexpression + (subexpression_token + (literal + (number_literal)))) + (operator) + (subexpression + (subexpression_token + (literal + (number_literal)))))))))) + (extended_name + (name_identifier)) + (subexpression_token + (name_expression + (extended_name + (name_identifier))))))) + (expression + (subexpression + (subexpression_token + (literal + (string_literal)))))) + (match_case + (pattern + (extended_name + (name_identifier))) + (expression + (subexpression + (function_call_expression + (subexpression_token + (scoped_statement + (superexpression + (expression + (subexpression + (binary_operator_expression + (subexpression + (subexpression_token + (literal + (number_literal)))) + (operator) + (subexpression + (subexpression_token + (literal + (number_literal)))))))))) + (extended_name + (name_identifier)) + (subexpression_token + (name_expression + (extended_name + (name_identifier))))))) + (expression + (subexpression + (subexpression_token + (literal + (string_literal)))))) + (match_case + (pattern + (extended_name + (name_identifier))) + (expression + (subexpression + (subexpression_token + (literal + (string_literal))))))))))) + (block_statement + (prefixed_expression + (return_expression (expression (subexpression (subexpression_token (name_expression (extended_name - (name_identifier)))))) - (match_case - (pattern - (pattern_token - (literal - (number_literal)))) - (expression - (subexpression - (function_call_expression - (extended_name - (name_identifier)) - (function_argument - (subexpression_token - (literal - (unit_literal))))))) - (expression - (subexpression - (subexpression_token - (literal - (string_literal)))))) - (match_case - (pattern - (pattern_token - (literal - (number_literal))))) - (match_case - (pattern - (pattern_token - (literal - (number_literal))))) - (match_case - (pattern - (pattern_token - (literal - (number_literal))))) - (match_case - (pattern - (pattern_token - (literal - (number_literal))))) - (match_case - (pattern - (pattern_token - (literal - (number_literal)))) - (expression - (subexpression - (subexpression_token - (literal - (string_literal)))))) - (match_case - (pattern - (pattern_token - (extended_name - (name_identifier)))) - (expression - (subexpression - (function_call_expression - (subexpression_token - (scoped_statement - (superexpression - (expression - (subexpression - (binary_operator_expression - (subexpression - (subexpression_token - (literal - (number_literal)))) - (operator) - (subexpression - (subexpression_token - (literal - (number_literal)))))))))) - (extended_name - (name_identifier)) - (function_argument - (subexpression_token - (name_expression - (extended_name - (name_identifier)))))))) - (expression - (subexpression - (subexpression_token - (literal - (string_literal)))))) - (match_case - (pattern - (pattern_token - (extended_name - (name_identifier)))) - (expression - (subexpression - (function_call_expression - (subexpression_token - (scoped_statement - (superexpression - (expression - (subexpression - (binary_operator_expression - (subexpression - (subexpression_token - (literal - (number_literal)))) - (operator) - (subexpression - (subexpression_token - (literal - (number_literal)))))))))) - (extended_name - (name_identifier)) - (function_argument - (subexpression_token - (name_expression - (extended_name - (name_identifier)))))))) - (expression - (subexpression - (subexpression_token - (literal - (string_literal)))))) - (match_case - (pattern - (pattern_token - (extended_name - (name_identifier)))) - (expression - (subexpression - (subexpression_token - (literal - (string_literal))))))))))) - (block_statement - (prefixed_expression - (return_expression - (expression - (subexpression - (subexpression_token - (name_expression - (extended_name - (name_identifier)))))))))))))))) + (name_identifier)))))))))))))))))) diff --git a/tests/memory.lang b/tests/memory.lang index 6419e3f..087dad3 100644 --- a/tests/memory.lang +++ b/tests/memory.lang @@ -3,6 +3,6 @@ struct StructWithRef = decl test_memory : Unit -> Unit def test_memory = { - const @unique_ref1 <- Int.@_new 5 - var @unique_ref2 <- Array.@of 1 2 3 + const @unique_ref1 <- Int.@_new: 5 + var @unique_ref2 <- Array.@of: 1 2 3 } diff --git a/tests/tuples.lang b/tests/tuples.lang index c75e0bf..c4613b1 100644 --- a/tests/tuples.lang +++ b/tests/tuples.lang @@ -1,7 +1,8 @@ decl test_tuples : Unit -> Unit def test_tuples = { var tuple1 = & "a" & 2 & "hello" - const & t1 & t2 & t3 = f x + const & t1 & t2 & t3 = f: x - ; tuple1:0 = "b" + ; tuple1`0 = "b" + } diff --git a/tests/type_casting.lang b/tests/type_casting.lang index 4622286..afd22ff 100644 --- a/tests/type_casting.lang +++ b/tests/type_casting.lang @@ -1,5 +1,5 @@ decl test_type_casting : Unit -> Unit def test_type_casting = { - var x = y.as Int - var k = (f y x).as Float + var x = y.as Int: + var k = (f: y x).as Float: } diff --git a/tests/typeclasses.lang b/tests/typeclasses.lang index e42a7a0..d85e022 100644 --- a/tests/typeclasses.lang +++ b/tests/typeclasses.lang @@ -11,10 +11,10 @@ typeclass E 'A = & do_something : Unit -> 'A decl ( == ) ('A : #Ord) : 'A -> 'A -> Bool -def ( == ) : a b = a.is_equal_to b +def ( == ) : a b = a.is_equal_to: b decl ( < ) ('A : #Ord) : 'A -> 'A -> Bool -def ( < ) : a b = a.is_less_then b +def ( < ) : a b = a.is_less_then: b decl ( > ) ('A : #Ord) : 'A -> 'A -> Bool def ( > ) : a b = !(a <= b) diff --git a/tests/types.lang b/tests/types.lang index a27b3db..5177be2 100644 --- a/tests/types.lang +++ b/tests/types.lang @@ -15,39 +15,45 @@ let T2 = Complex (source_file (source_statement - (alias_definition_statement - (type_identifier) - (type_expression - (type_subexpression - (type_identifier))))) + (partition_statement + (namespace_statement + (alias_definition_statement + (type_identifier) + (type_expression + (parametrized_type + (type_identifier))))))) (source_statement - (abstract_type_definition_statement - (annotated_type - (type_identifier) - (typeclass_expression - (typeclass_subexpression - (typeclass_identifier))) - (typeclass_expression - (typeclass_subexpression - (typeclass_identifier))) - (typeclass_expression - (typeclass_subexpression + (partition_statement + (abstract_type_definition_statement + (annotated_type + (type_identifier) + (parametrized_typeclass + (typeclass_identifier)) + (parametrized_typeclass + (typeclass_identifier)) + (parametrized_typeclass (typeclass_identifier)))))) (source_statement - (alias_definition_statement - (type_identifier) - (type_expression - (type_subexpression - (type_identifier))))) + (partition_statement + (namespace_statement + (alias_definition_statement + (type_identifier) + (type_expression + (parametrized_type + (type_identifier))))))) (source_statement - (alias_definition_statement - (type_identifier) - (type_expression - (type_subexpression - (type_identifier))))) + (partition_statement + (namespace_statement + (alias_definition_statement + (type_identifier) + (type_expression + (parametrized_type + (type_identifier))))))) (source_statement - (alias_definition_statement - (type_identifier) - (type_expression - (type_subexpression - (type_identifier)))))) + (partition_statement + (namespace_statement + (alias_definition_statement + (type_identifier) + (type_expression + (parametrized_type + (type_identifier)))))))) diff --git a/tests/variants.lang b/tests/variants.lang index 4317c7a..5fc3f59 100644 --- a/tests/variants.lang +++ b/tests/variants.lang @@ -1,7 +1,7 @@ decl test_variants : Unit -> Unit def test_variants = { var variant1 = | 'a' | 2 | "hello" - var | val | err = f x + var | val | err = f: x ; val -?> "something" // open variant as value in expr