From 4a03cffa1c436f6dddec8adc2957d82fdaeb6d82 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Mon, 29 Jan 2024 15:24:08 -0800 Subject: [PATCH 01/14] first-pass rearranging things --- tests/lang/s02_core/README.md | 16 +++++++++------- .../lang/s02_core/s08_evaluation_order/README.md | 2 +- tests/lang/s03_templating/readme.md | 5 +++++ tests/lang/s04_parapoly/readme.md | 8 ++++++++ tests/lang/s04_warnings_and_hints/readme.md | 2 -- .../README.md | 0 tests/lang/s07_comptime/readme.md | 4 ++++ tests/lang/s08_metaprogramming/readme.md | 5 +++++ .../lang/{s05_pragmas => s09_pragmas}/readme.md | 0 .../s01_interop/readme.md | 0 .../s01_interop/t01_c_interop.nim | 0 .../s01_interop/t01_c_interop.nim.c | 0 .../s01_interop/t01_c_interop.nim.h | 0 .../s01_interop/t02_emit_c.nim | 0 .../s01_interop/t03_exported_constants.nim | 0 .../s01_interop/t04_imported_constants.nim | 0 .../s02_misc/readme.md | 0 .../s02_misc/t01_ident_pragmas.nim | 0 .../s02_misc/t02_flag_pragmas.nim | 0 .../s02_misc/t03_hint_pragmas.nim | 0 .../s02_misc/t04_warning.nim | 0 .../s02_misc/t05_procedure.nim | 0 .../s02_misc/t06_union_pragma.nim | 0 .../readme.md | 0 .../s01_views/s00_bugs/t01_var_openarray.nim | 0 .../s01_views/s00_bugs/t02_borrow_literal.nim | 0 .../s01_views/s01_path_expressions/readme.md | 0 .../t01_trivial_borrow_fail.nim | 0 .../t02_container_borrow_fail.nim | 0 .../t03_tuple_borrow_fail.nim | 0 .../t04_field_borrow_fail.nim | 0 .../t05_to_openarray_borrow_fail.nim | 0 .../t06_pointer_deref_borrow_fail.nim | 0 .../t07_addr_borrow_fail.nim | 0 .../t08_type_conversion_borrow_fail.nim | 0 .../t09_proc_param_borrow_fail.nim | 0 .../s01_views/s02_array_views.nim | 0 .../s01_views/t01_array_fail_sealed_borrow.nim | 0 38 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 tests/lang/s03_templating/readme.md create mode 100644 tests/lang/s04_parapoly/readme.md delete mode 100644 tests/lang/s04_warnings_and_hints/readme.md rename tests/lang/{s03_module_system => s06_module_system}/README.md (100%) create mode 100644 tests/lang/s07_comptime/readme.md create mode 100644 tests/lang/s08_metaprogramming/readme.md rename tests/lang/{s05_pragmas => s09_pragmas}/readme.md (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s01_interop/readme.md (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s01_interop/t01_c_interop.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s01_interop/t01_c_interop.nim.c (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s01_interop/t01_c_interop.nim.h (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s01_interop/t02_emit_c.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s01_interop/t03_exported_constants.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s01_interop/t04_imported_constants.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s02_misc/readme.md (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s02_misc/t01_ident_pragmas.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s02_misc/t02_flag_pragmas.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s02_misc/t03_hint_pragmas.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s02_misc/t04_warning.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s02_misc/t05_procedure.nim (100%) rename tests/lang/{s05_pragmas => s09_pragmas}/s02_misc/t06_union_pragma.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/readme.md (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s00_bugs/t01_var_openarray.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s00_bugs/t02_borrow_literal.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/readme.md (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t01_trivial_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t02_container_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t03_tuple_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t04_field_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t05_to_openarray_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t06_pointer_deref_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t07_addr_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t08_type_conversion_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s01_path_expressions/t09_proc_param_borrow_fail.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/s02_array_views.nim (100%) rename tests/lang/{s06_experimental => s10_experimental}/s01_views/t01_array_fail_sealed_borrow.nim (100%) diff --git a/tests/lang/s02_core/README.md b/tests/lang/s02_core/README.md index 02b530f0a0d..5a855819130 100644 --- a/tests/lang/s02_core/README.md +++ b/tests/lang/s02_core/README.md @@ -1,13 +1,15 @@ # What Belongs Here? This is the core of the language, but prior to the higher level features, this -would be what one might use to write a bootstrap Nim compiler which does not -possess all the features of Nim. +would be what one might use to write a basic bootstrap Nimskull compiler for a +barebones/basic Nimskull (no generics, metaprogramming, effects, etc). -- User-defined data types - generic, regular types, inheritance -- inline iterators -- procedures - `func`, `proc` and `converter`. Overload resolution rules for generic - and regular procedures. Methods +- elaboration of evaluation order +- user-defined data types - concrete types and basic parametric polymorphism +- procedures - overload resolution + +Everything below doesn't belong in the core: +- iterators - Effect and exception tracking system - Templates -- Macros and macro API +- Macros diff --git a/tests/lang/s02_core/s08_evaluation_order/README.md b/tests/lang/s02_core/s08_evaluation_order/README.md index c7696a5b7d5..c67cb7e362f 100644 --- a/tests/lang/s02_core/s08_evaluation_order/README.md +++ b/tests/lang/s02_core/s08_evaluation_order/README.md @@ -4,7 +4,7 @@ This section contains tests for inter- and intra-evaluation-order of expressions and their sub-expressions. The tests document where and how effects of expression are observable -- - without effectful expression (i.e., expression that do more than just return +without effectful expression (i.e., expression that do more than just return a value), order of evaluation would not matter. ## Assumptions diff --git a/tests/lang/s03_templating/readme.md b/tests/lang/s03_templating/readme.md new file mode 100644 index 00000000000..1966669f9d8 --- /dev/null +++ b/tests/lang/s03_templating/readme.md @@ -0,0 +1,5 @@ +# What Belongs Here? + +Introduction of templating facilities into the language, primarily `template` +routines, their calling, and interaction with overloads. Including `typed` and +`untyped` parameters and inline iterator support. \ No newline at end of file diff --git a/tests/lang/s04_parapoly/readme.md b/tests/lang/s04_parapoly/readme.md new file mode 100644 index 00000000000..c2d472c253e --- /dev/null +++ b/tests/lang/s04_parapoly/readme.md @@ -0,0 +1,8 @@ +# What Belongs Here? + +Support for Parametric Polymorphism (parapoly), or generics. This has +implications for data types and procedures. This is exclusive of implicit +generics/type parameters, but includes first class iterators. + +TODO: confirm if first class iterators should be here, combined with an earlier + section, or separated into their own thing. \ No newline at end of file diff --git a/tests/lang/s04_warnings_and_hints/readme.md b/tests/lang/s04_warnings_and_hints/readme.md deleted file mode 100644 index 09b54056b66..00000000000 --- a/tests/lang/s04_warnings_and_hints/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -Tests in this section are used to describe and illustrate compiler -warnings and hints in one place. \ No newline at end of file diff --git a/tests/lang/s03_module_system/README.md b/tests/lang/s06_module_system/README.md similarity index 100% rename from tests/lang/s03_module_system/README.md rename to tests/lang/s06_module_system/README.md diff --git a/tests/lang/s07_comptime/readme.md b/tests/lang/s07_comptime/readme.md new file mode 100644 index 00000000000..b150deb8336 --- /dev/null +++ b/tests/lang/s07_comptime/readme.md @@ -0,0 +1,4 @@ +# What Belongs Here? + +Compile Time evaluation, or compile time. This includes the introduction of +`typedesc` and implicit generics. \ No newline at end of file diff --git a/tests/lang/s08_metaprogramming/readme.md b/tests/lang/s08_metaprogramming/readme.md new file mode 100644 index 00000000000..00f2a719ba9 --- /dev/null +++ b/tests/lang/s08_metaprogramming/readme.md @@ -0,0 +1,5 @@ +# What Belongs Here? + +Introduction of macros and barebones API, this also includes the distinction of +`typed` vs `untyped` parameters. + diff --git a/tests/lang/s05_pragmas/readme.md b/tests/lang/s09_pragmas/readme.md similarity index 100% rename from tests/lang/s05_pragmas/readme.md rename to tests/lang/s09_pragmas/readme.md diff --git a/tests/lang/s05_pragmas/s01_interop/readme.md b/tests/lang/s09_pragmas/s01_interop/readme.md similarity index 100% rename from tests/lang/s05_pragmas/s01_interop/readme.md rename to tests/lang/s09_pragmas/s01_interop/readme.md diff --git a/tests/lang/s05_pragmas/s01_interop/t01_c_interop.nim b/tests/lang/s09_pragmas/s01_interop/t01_c_interop.nim similarity index 100% rename from tests/lang/s05_pragmas/s01_interop/t01_c_interop.nim rename to tests/lang/s09_pragmas/s01_interop/t01_c_interop.nim diff --git a/tests/lang/s05_pragmas/s01_interop/t01_c_interop.nim.c b/tests/lang/s09_pragmas/s01_interop/t01_c_interop.nim.c similarity index 100% rename from tests/lang/s05_pragmas/s01_interop/t01_c_interop.nim.c rename to tests/lang/s09_pragmas/s01_interop/t01_c_interop.nim.c diff --git a/tests/lang/s05_pragmas/s01_interop/t01_c_interop.nim.h b/tests/lang/s09_pragmas/s01_interop/t01_c_interop.nim.h similarity index 100% rename from tests/lang/s05_pragmas/s01_interop/t01_c_interop.nim.h rename to tests/lang/s09_pragmas/s01_interop/t01_c_interop.nim.h diff --git a/tests/lang/s05_pragmas/s01_interop/t02_emit_c.nim b/tests/lang/s09_pragmas/s01_interop/t02_emit_c.nim similarity index 100% rename from tests/lang/s05_pragmas/s01_interop/t02_emit_c.nim rename to tests/lang/s09_pragmas/s01_interop/t02_emit_c.nim diff --git a/tests/lang/s05_pragmas/s01_interop/t03_exported_constants.nim b/tests/lang/s09_pragmas/s01_interop/t03_exported_constants.nim similarity index 100% rename from tests/lang/s05_pragmas/s01_interop/t03_exported_constants.nim rename to tests/lang/s09_pragmas/s01_interop/t03_exported_constants.nim diff --git a/tests/lang/s05_pragmas/s01_interop/t04_imported_constants.nim b/tests/lang/s09_pragmas/s01_interop/t04_imported_constants.nim similarity index 100% rename from tests/lang/s05_pragmas/s01_interop/t04_imported_constants.nim rename to tests/lang/s09_pragmas/s01_interop/t04_imported_constants.nim diff --git a/tests/lang/s05_pragmas/s02_misc/readme.md b/tests/lang/s09_pragmas/s02_misc/readme.md similarity index 100% rename from tests/lang/s05_pragmas/s02_misc/readme.md rename to tests/lang/s09_pragmas/s02_misc/readme.md diff --git a/tests/lang/s05_pragmas/s02_misc/t01_ident_pragmas.nim b/tests/lang/s09_pragmas/s02_misc/t01_ident_pragmas.nim similarity index 100% rename from tests/lang/s05_pragmas/s02_misc/t01_ident_pragmas.nim rename to tests/lang/s09_pragmas/s02_misc/t01_ident_pragmas.nim diff --git a/tests/lang/s05_pragmas/s02_misc/t02_flag_pragmas.nim b/tests/lang/s09_pragmas/s02_misc/t02_flag_pragmas.nim similarity index 100% rename from tests/lang/s05_pragmas/s02_misc/t02_flag_pragmas.nim rename to tests/lang/s09_pragmas/s02_misc/t02_flag_pragmas.nim diff --git a/tests/lang/s05_pragmas/s02_misc/t03_hint_pragmas.nim b/tests/lang/s09_pragmas/s02_misc/t03_hint_pragmas.nim similarity index 100% rename from tests/lang/s05_pragmas/s02_misc/t03_hint_pragmas.nim rename to tests/lang/s09_pragmas/s02_misc/t03_hint_pragmas.nim diff --git a/tests/lang/s05_pragmas/s02_misc/t04_warning.nim b/tests/lang/s09_pragmas/s02_misc/t04_warning.nim similarity index 100% rename from tests/lang/s05_pragmas/s02_misc/t04_warning.nim rename to tests/lang/s09_pragmas/s02_misc/t04_warning.nim diff --git a/tests/lang/s05_pragmas/s02_misc/t05_procedure.nim b/tests/lang/s09_pragmas/s02_misc/t05_procedure.nim similarity index 100% rename from tests/lang/s05_pragmas/s02_misc/t05_procedure.nim rename to tests/lang/s09_pragmas/s02_misc/t05_procedure.nim diff --git a/tests/lang/s05_pragmas/s02_misc/t06_union_pragma.nim b/tests/lang/s09_pragmas/s02_misc/t06_union_pragma.nim similarity index 100% rename from tests/lang/s05_pragmas/s02_misc/t06_union_pragma.nim rename to tests/lang/s09_pragmas/s02_misc/t06_union_pragma.nim diff --git a/tests/lang/s06_experimental/readme.md b/tests/lang/s10_experimental/readme.md similarity index 100% rename from tests/lang/s06_experimental/readme.md rename to tests/lang/s10_experimental/readme.md diff --git a/tests/lang/s06_experimental/s01_views/s00_bugs/t01_var_openarray.nim b/tests/lang/s10_experimental/s01_views/s00_bugs/t01_var_openarray.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s00_bugs/t01_var_openarray.nim rename to tests/lang/s10_experimental/s01_views/s00_bugs/t01_var_openarray.nim diff --git a/tests/lang/s06_experimental/s01_views/s00_bugs/t02_borrow_literal.nim b/tests/lang/s10_experimental/s01_views/s00_bugs/t02_borrow_literal.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s00_bugs/t02_borrow_literal.nim rename to tests/lang/s10_experimental/s01_views/s00_bugs/t02_borrow_literal.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/readme.md b/tests/lang/s10_experimental/s01_views/s01_path_expressions/readme.md similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/readme.md rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/readme.md diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t01_trivial_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t01_trivial_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t01_trivial_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t01_trivial_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t02_container_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t02_container_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t02_container_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t02_container_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t03_tuple_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t03_tuple_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t03_tuple_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t03_tuple_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t04_field_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t04_field_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t04_field_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t04_field_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t05_to_openarray_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t05_to_openarray_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t05_to_openarray_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t05_to_openarray_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t06_pointer_deref_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t06_pointer_deref_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t06_pointer_deref_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t06_pointer_deref_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t07_addr_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t07_addr_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t07_addr_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t07_addr_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t08_type_conversion_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t08_type_conversion_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t08_type_conversion_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t08_type_conversion_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s01_path_expressions/t09_proc_param_borrow_fail.nim b/tests/lang/s10_experimental/s01_views/s01_path_expressions/t09_proc_param_borrow_fail.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s01_path_expressions/t09_proc_param_borrow_fail.nim rename to tests/lang/s10_experimental/s01_views/s01_path_expressions/t09_proc_param_borrow_fail.nim diff --git a/tests/lang/s06_experimental/s01_views/s02_array_views.nim b/tests/lang/s10_experimental/s01_views/s02_array_views.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/s02_array_views.nim rename to tests/lang/s10_experimental/s01_views/s02_array_views.nim diff --git a/tests/lang/s06_experimental/s01_views/t01_array_fail_sealed_borrow.nim b/tests/lang/s10_experimental/s01_views/t01_array_fail_sealed_borrow.nim similarity index 100% rename from tests/lang/s06_experimental/s01_views/t01_array_fail_sealed_borrow.nim rename to tests/lang/s10_experimental/s01_views/t01_array_fail_sealed_borrow.nim From 83c786407a1bd363e7bbbc02dd39395f68cf1a57 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Thu, 8 Feb 2024 15:19:49 -0800 Subject: [PATCH 02/14] imports and includes shouldn't be in core that stuff is after we have a module system, and includes are more template related. --- tests/lang/s02_core/s02_procedures/sample_types_import.nim | 2 ++ tests/lang/s02_core/s02_procedures/sample_types_include.nim | 1 + 2 files changed, 3 insertions(+) diff --git a/tests/lang/s02_core/s02_procedures/sample_types_import.nim b/tests/lang/s02_core/s02_procedures/sample_types_import.nim index 208282108a9..dbb494b524f 100644 --- a/tests/lang/s02_core/s02_procedures/sample_types_import.nim +++ b/tests/lang/s02_core/s02_procedures/sample_types_import.nim @@ -1,5 +1,7 @@ ## Example type definitions to be used in the procedure calls. +# TODO no imports in this section of tests + type ImRange = range[0 .. 10] ImArray = array[3, int] diff --git a/tests/lang/s02_core/s02_procedures/sample_types_include.nim b/tests/lang/s02_core/s02_procedures/sample_types_include.nim index e69de29bb2d..89d5bfa58d5 100644 --- a/tests/lang/s02_core/s02_procedures/sample_types_include.nim +++ b/tests/lang/s02_core/s02_procedures/sample_types_include.nim @@ -0,0 +1 @@ +# TODO no includes in this section of tests \ No newline at end of file From 78222758d6d26ced602a708ba1fd8f179f868a97 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Thu, 8 Feb 2024 15:21:49 -0800 Subject: [PATCH 03/14] move `lang_defs` into `lang_types` it made no sense to have them separately --- tests/lang_defs/readme.md | 1 - tests/{lang_defs => lang_types}/distinct/tdistinct.nim | 0 tests/{lang_defs => lang_types}/distinct/tdistinct_coerce.nim | 0 .../distinct/tdistinct_disallow_recursion.nim | 0 tests/{lang_defs => lang_types}/distinct/tdistinct_issues.nim | 0 tests/{lang_defs => lang_types}/distinct/tnil.nim | 0 tests/{lang_defs => lang_types}/enum/mregression.nim | 0 tests/{lang_defs => lang_types}/enum/tenum.nim | 0 tests/{lang_defs => lang_types}/enum/tenum_no_rtti.nim | 0 tests/{lang_defs => lang_types}/enum/tenum_self.nim | 0 .../enum/tenumconvdetectlitoutofrange.nim | 0 tests/{lang_defs => lang_types}/enum/tenumfieldpragma.nim | 0 tests/{lang_defs => lang_types}/enum/tenumfieldpragmanoannot.nim | 0 tests/{lang_defs => lang_types}/enum/tenumitems.nim | 0 tests/{lang_defs => lang_types}/enum/tenumitems2.nim | 0 tests/{lang_defs => lang_types}/enum/tenummix.nim | 0 tests/{lang_defs => lang_types}/enum/toverloadable_enums.nim | 0 tests/{lang_defs => lang_types}/enum/tpure_enums_conflict.nim | 0 tests/{lang_defs => lang_types}/enum/tregression.nim | 0 tests/{lang_defs => lang_types}/enum/tstored_as_unsigned.nim | 0 20 files changed, 1 deletion(-) delete mode 100644 tests/lang_defs/readme.md rename tests/{lang_defs => lang_types}/distinct/tdistinct.nim (100%) rename tests/{lang_defs => lang_types}/distinct/tdistinct_coerce.nim (100%) rename tests/{lang_defs => lang_types}/distinct/tdistinct_disallow_recursion.nim (100%) rename tests/{lang_defs => lang_types}/distinct/tdistinct_issues.nim (100%) rename tests/{lang_defs => lang_types}/distinct/tnil.nim (100%) rename tests/{lang_defs => lang_types}/enum/mregression.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenum.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenum_no_rtti.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenum_self.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenumconvdetectlitoutofrange.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenumfieldpragma.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenumfieldpragmanoannot.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenumitems.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenumitems2.nim (100%) rename tests/{lang_defs => lang_types}/enum/tenummix.nim (100%) rename tests/{lang_defs => lang_types}/enum/toverloadable_enums.nim (100%) rename tests/{lang_defs => lang_types}/enum/tpure_enums_conflict.nim (100%) rename tests/{lang_defs => lang_types}/enum/tregression.nim (100%) rename tests/{lang_defs => lang_types}/enum/tstored_as_unsigned.nim (100%) diff --git a/tests/lang_defs/readme.md b/tests/lang_defs/readme.md deleted file mode 100644 index 05f2b327b3f..00000000000 --- a/tests/lang_defs/readme.md +++ /dev/null @@ -1 +0,0 @@ -Additional tests for language construct defintions: procedures, macros, templates \ No newline at end of file diff --git a/tests/lang_defs/distinct/tdistinct.nim b/tests/lang_types/distinct/tdistinct.nim similarity index 100% rename from tests/lang_defs/distinct/tdistinct.nim rename to tests/lang_types/distinct/tdistinct.nim diff --git a/tests/lang_defs/distinct/tdistinct_coerce.nim b/tests/lang_types/distinct/tdistinct_coerce.nim similarity index 100% rename from tests/lang_defs/distinct/tdistinct_coerce.nim rename to tests/lang_types/distinct/tdistinct_coerce.nim diff --git a/tests/lang_defs/distinct/tdistinct_disallow_recursion.nim b/tests/lang_types/distinct/tdistinct_disallow_recursion.nim similarity index 100% rename from tests/lang_defs/distinct/tdistinct_disallow_recursion.nim rename to tests/lang_types/distinct/tdistinct_disallow_recursion.nim diff --git a/tests/lang_defs/distinct/tdistinct_issues.nim b/tests/lang_types/distinct/tdistinct_issues.nim similarity index 100% rename from tests/lang_defs/distinct/tdistinct_issues.nim rename to tests/lang_types/distinct/tdistinct_issues.nim diff --git a/tests/lang_defs/distinct/tnil.nim b/tests/lang_types/distinct/tnil.nim similarity index 100% rename from tests/lang_defs/distinct/tnil.nim rename to tests/lang_types/distinct/tnil.nim diff --git a/tests/lang_defs/enum/mregression.nim b/tests/lang_types/enum/mregression.nim similarity index 100% rename from tests/lang_defs/enum/mregression.nim rename to tests/lang_types/enum/mregression.nim diff --git a/tests/lang_defs/enum/tenum.nim b/tests/lang_types/enum/tenum.nim similarity index 100% rename from tests/lang_defs/enum/tenum.nim rename to tests/lang_types/enum/tenum.nim diff --git a/tests/lang_defs/enum/tenum_no_rtti.nim b/tests/lang_types/enum/tenum_no_rtti.nim similarity index 100% rename from tests/lang_defs/enum/tenum_no_rtti.nim rename to tests/lang_types/enum/tenum_no_rtti.nim diff --git a/tests/lang_defs/enum/tenum_self.nim b/tests/lang_types/enum/tenum_self.nim similarity index 100% rename from tests/lang_defs/enum/tenum_self.nim rename to tests/lang_types/enum/tenum_self.nim diff --git a/tests/lang_defs/enum/tenumconvdetectlitoutofrange.nim b/tests/lang_types/enum/tenumconvdetectlitoutofrange.nim similarity index 100% rename from tests/lang_defs/enum/tenumconvdetectlitoutofrange.nim rename to tests/lang_types/enum/tenumconvdetectlitoutofrange.nim diff --git a/tests/lang_defs/enum/tenumfieldpragma.nim b/tests/lang_types/enum/tenumfieldpragma.nim similarity index 100% rename from tests/lang_defs/enum/tenumfieldpragma.nim rename to tests/lang_types/enum/tenumfieldpragma.nim diff --git a/tests/lang_defs/enum/tenumfieldpragmanoannot.nim b/tests/lang_types/enum/tenumfieldpragmanoannot.nim similarity index 100% rename from tests/lang_defs/enum/tenumfieldpragmanoannot.nim rename to tests/lang_types/enum/tenumfieldpragmanoannot.nim diff --git a/tests/lang_defs/enum/tenumitems.nim b/tests/lang_types/enum/tenumitems.nim similarity index 100% rename from tests/lang_defs/enum/tenumitems.nim rename to tests/lang_types/enum/tenumitems.nim diff --git a/tests/lang_defs/enum/tenumitems2.nim b/tests/lang_types/enum/tenumitems2.nim similarity index 100% rename from tests/lang_defs/enum/tenumitems2.nim rename to tests/lang_types/enum/tenumitems2.nim diff --git a/tests/lang_defs/enum/tenummix.nim b/tests/lang_types/enum/tenummix.nim similarity index 100% rename from tests/lang_defs/enum/tenummix.nim rename to tests/lang_types/enum/tenummix.nim diff --git a/tests/lang_defs/enum/toverloadable_enums.nim b/tests/lang_types/enum/toverloadable_enums.nim similarity index 100% rename from tests/lang_defs/enum/toverloadable_enums.nim rename to tests/lang_types/enum/toverloadable_enums.nim diff --git a/tests/lang_defs/enum/tpure_enums_conflict.nim b/tests/lang_types/enum/tpure_enums_conflict.nim similarity index 100% rename from tests/lang_defs/enum/tpure_enums_conflict.nim rename to tests/lang_types/enum/tpure_enums_conflict.nim diff --git a/tests/lang_defs/enum/tregression.nim b/tests/lang_types/enum/tregression.nim similarity index 100% rename from tests/lang_defs/enum/tregression.nim rename to tests/lang_types/enum/tregression.nim diff --git a/tests/lang_defs/enum/tstored_as_unsigned.nim b/tests/lang_types/enum/tstored_as_unsigned.nim similarity index 100% rename from tests/lang_defs/enum/tstored_as_unsigned.nim rename to tests/lang_types/enum/tstored_as_unsigned.nim From 88b975c08de410e940435566c8668c7382dae14d Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Thu, 8 Feb 2024 15:23:22 -0800 Subject: [PATCH 04/14] further refine parametric polymorphism section along with a few minor clean-ups in `lang` --- .../s02_procedures/t02_argument_passing.nim | 7 ++ ...1_varargs_does_not_support_polymorphic.nim | 41 --------- .../s02_procedures/t03_overload_core.nim | 91 +------------------ .../t01_ref_object_is_not_a_subtype.nim | 19 ++-- .../t02_tuple_matches_for_enum_constaint.nim | 22 ----- .../t03_overload_core_conversion/readme.md | 4 - .../t01_overload_core_ambiguous_fail.nim | 16 ++++ .../t03_overload_core_ambiguous_fail.nim | 15 --- tests/lang/s03_templating/readme.md | 5 +- tests/lang/s04_parapoly/readme.md | 6 +- .../t01_non_distinct_typeclass_error.nim | 12 +-- .../s03_overload/t01_generic_overloads.nim | 83 +++++++++++++++++ .../t02_varargs_polymorphic_generic.nim | 55 +++++++++++ ...t04_generic_and_subtype_matches_widest.nim | 0 .../lang/s04_parapoly/s04_typeclass/readme.md | 7 ++ .../s04_typeclass/t01_typeclass.nim} | 3 + ..._matches_for_enum_typeclass_constraint.nim | 23 +++++ ...peclasses_bug_constraint_is_ambiguous.nim} | 15 +-- .../s04_parapoly/s05_converters/readme.md | 4 + .../s05_converters}/t01_generic_converter.nim | 0 tests/lang/s05_pragmas/readme.md | 5 + .../t01_regular_procs_dot_operators.nim | 2 +- 22 files changed, 238 insertions(+), 197 deletions(-) delete mode 100644 tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t02_tuple_matches_for_enum_constaint.nim delete mode 100644 tests/lang/s02_core/s02_procedures/t03_overload_core_conversion/readme.md create mode 100644 tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim delete mode 100644 tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t03_overload_core_ambiguous_fail.nim rename tests/lang/{s02_core/s02_procedures/t03_overload_core_errors => s04_parapoly/s03_overload/s01_generic_overload_errors}/t01_non_distinct_typeclass_error.nim (84%) create mode 100644 tests/lang/s04_parapoly/s03_overload/t01_generic_overloads.nim create mode 100644 tests/lang/s04_parapoly/s03_overload/t02_varargs_polymorphic_generic.nim rename tests/lang/{s02_core/s02_procedures/t03_overload_core_bugs => s04_parapoly/s03_overload}/t04_generic_and_subtype_matches_widest.nim (100%) create mode 100644 tests/lang/s04_parapoly/s04_typeclass/readme.md rename tests/lang/{s02_core/s01_user_defined_data_types/t07_typeclass.nim => s04_parapoly/s04_typeclass/t01_typeclass.nim} (84%) create mode 100644 tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim rename tests/lang/{s02_core/s02_procedures/t03_overload_core_bugs/t05_typeclass_constaint_is_ambiguous.nim => s04_parapoly/s04_typeclass/t03_typeclasses_bug_constraint_is_ambiguous.nim} (62%) create mode 100644 tests/lang/s04_parapoly/s05_converters/readme.md rename tests/lang/{s02_core/s02_procedures/t03_overload_core_conversion => s04_parapoly/s05_converters}/t01_generic_converter.nim (100%) create mode 100644 tests/lang/s05_pragmas/readme.md rename tests/lang/{s02_core/s02_procedures => s10_experimental}/t01_regular_procs_dot_operators.nim (78%) diff --git a/tests/lang/s02_core/s02_procedures/t02_argument_passing.nim b/tests/lang/s02_core/s02_procedures/t02_argument_passing.nim index 26c33b1f400..d8280ec0890 100644 --- a/tests/lang/s02_core/s02_procedures/t02_argument_passing.nim +++ b/tests/lang/s02_core/s02_procedures/t02_argument_passing.nim @@ -4,6 +4,13 @@ Covers the multitude of ways you can pass arguments to procedures. ''' """ +# TODO: break things out as more advanced sections: +# - variadics should be their own spec +# - variadic with conversion, is yet more complicated +# - syntax: separate dot call rewrites +# - named arguments +# - default arguments + block different_number_of_arguments: ## Procedures can accept zero or more arguments. diff --git a/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim b/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim index 95bfbdc5ca5..d474579485e 100644 --- a/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim +++ b/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim @@ -12,7 +12,6 @@ be used to achieve desired behavior. ''' knownIssue: "varargs cannot pass polymorphic derived types" - """ var invalidAssings: seq[string] @@ -49,43 +48,3 @@ block regular_types: except ObjectAssignmentDefect: invalidAssings.add "Derived1(), Derived2()" - - -block: - type - Base[T] = object of RootObj - value: T - Derived1[T] = object of Base[T] - Derived2[T] = object of Base[T] - - - proc implRegular[T](a, b, c: Base[T]): string = - result.add $a.value - result.add $b.value - result.add $c.value - - proc implVarargs[T](x: varargs[Base[T]]): string = - discard - # result = "" - # for c in x: - # result.add $c.value - - doAssert implRegular( - Derived2[int](value: 2), - Derived1[int](value: 4), - Base[int](value: 3) - ) == "243", "Passing subtypes using regular arguments works correctly" - - try: - doAssert implVarargs( - Derived2[int](value: 2), - Derived1[int](value: 4), - Base[int](value: 3) - ) == "243", "Passing subtypes via varargs must work the same way as mutliple arguments" - - except ObjectAssignmentdefect: - invalidAssings.add "Derived1, Derived, Base" - - -doAssert invalidAssings.len == 0, "Failed object assignment for " & $invalidAssings.len & - " cases - " & $invalidAssings diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core.nim b/tests/lang/s02_core/s02_procedures/t03_overload_core.nim index d95bb2374db..76b0d3352a1 100644 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core.nim +++ b/tests/lang/s02_core/s02_procedures/t03_overload_core.nim @@ -1,12 +1,10 @@ discard """ -description: ''' -Specification of the core overloading resolution algorithm with examples -''' - + description: ''' + Specification of the core overloading resolution algorithm with examples + ''' """ - - +# TODO: breakout `convertors` into their own section, not part of the core ## In a call `p(args)` the routine `p` that matches best is selected. ## If multiple routines match equally well, the ambiguity is reported @@ -87,44 +85,6 @@ block subtype_match: doAssert impl(C()) == "matched subtype B" doAssert impl(B()) == "matched subtype B" - -block most_specific_generic_wins: - ## If multiple overloaded procedures are present, most specific is - ## always selected. - - block qualifier: - ## `ref`, `ptr` and other type qualifiers are counted as a part of - ## the generic procedure definition. - - proc gen[T](x: var ref ref T): string = "var ref ref T" - proc gen[T](x: ref ref T): string = "ref ref T" - proc gen[T](x: ref T): string = "ref T" - proc gen[T](x: T): string = "T" - - var v: ref ref int = nil - doAssert gen(v) == "var ref ref T" - doAssert gen((ref ref int)(nil)) == "ref ref T" - doAssert gen((ref int)(nil)) == "ref T" - doAssert gen(nil) == "T" - - - # QUESTION - it is not possible to select less generic overload? - # doAssert gen[ref ref ref ref int](nil) == "ref T" - - block regular: - ## The rule also applied to regular generic types - proc gen[T](x: var seq[seq[T]]): string = "var seq seq T" - proc gen[T](x: seq[seq[T]]): string = "seq seq T" - proc gen[T](x: seq[T]): string = "seq T" - proc gen[T](x: T): string = "T" - - var v: seq[seq[int]] - doAssert gen(v) == "var seq seq T" - doAssert gen(newSeq[seq[int]]()) == "seq seq T" - doAssert gen(newSeq[int]()) == "seq T" - doAssert gen(nil) == "T" - - block conversion_match: ## Conversion match: a is convertible to f, possibly via a user defined converter. @@ -151,49 +111,6 @@ block consider_all_arguments: ## it leads to the "ambiguous overload" error - ## :idx:`t03_overload_core_ambiguous_fail.nim` -block generic_vs_subtype: - ## Generic overloading match comes before subtype relation match, so maybe code - ## like this would seem unexpected. - # - # Example taken from the https://github.com/nim-lang/Nim/issues/18314 - # - type - A = ref object of RootObj - B = ref object of A - C = ref object of B - - block regular_procs: - proc impl[T: A](a: T): string = "matched generic" - proc impl(b: B): string = "matched subtype B" - - ## subtype vs generic - wins generic - doAssert impl(C()) == "matched generic" - - ## generic vs exact match - wins exact match - doAssert impl(B()) == "matched subtype B" - -block subtype_constaints_for_generic: - ## When subtype is used as a constraint for the generic parameter it - ## functions the same way as if it was written directly in the argument. - - type - A = ref object of RootObj - B1 = ref object of A - B2 = ref object of A - - proc impl[T](a: T): string = "T" - proc impl[T: A](a: T): string = "A" - proc impl[T: B1](a: T): string = "B1" - proc impl[T: B2](a: T): string = "B2" - proc impl[T: B1 | B2](a: T): string = "B1|B2" - - doAssert impl(B1()) == "B1" - doAssert impl(B2()) == "B2" - - ## Note that `B1 | B2` is not reported as an ambiguous overload since constaints - ## with alternatives have a lower precedence compared to the simple `SomeType`. - - ## Conveter must be defined on the toplevel - it is only used in the `varargs_overloading` ## example diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t01_ref_object_is_not_a_subtype.nim b/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t01_ref_object_is_not_a_subtype.nim index 4500fe36fd8..25e8c82ea1f 100644 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t01_ref_object_is_not_a_subtype.nim +++ b/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t01_ref_object_is_not_a_subtype.nim @@ -1,16 +1,15 @@ discard """ -description: ''' -Rejects valid code, or this part of the overload resolution is underspecified. - -`ref object` in definition is handled differently from `ref T` in the argument -when overload resolution is considered. -''' -knownIssue: "ref object is not a proper subtype" -errormsg: "Error: type mismatch: got " - + description: ''' + `ref object` in a definition is handled differently from `ref T` in an + argument when overload resolution is considered. + ''' + knownIssue: ''' + Rejects valid code or this part of the overload resolution is + underspecified. + ''' """ -# When fixed should be added back to the core overload resolution, "subtype" section +# When fixed should be added back to overload resolution with inheritance block subtype_ref_object: block no_qualifier: ## Identical to previous example, but used here to highlight lack of diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t02_tuple_matches_for_enum_constaint.nim b/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t02_tuple_matches_for_enum_constaint.nim deleted file mode 100644 index c394ddd0fa6..00000000000 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t02_tuple_matches_for_enum_constaint.nim +++ /dev/null @@ -1,22 +0,0 @@ -discard """ -description: ''' -Generic constraints for enum and tuple fail to resolve (ambigouus call) -if explicit generic parameter is used. When called without explicit parameter -(type inferred from the argument), code compiles correctly. -''' -knownIssue: "enum/tuple generic constraint fails to resolve (ambiguous)" -errormsg: "ambiguous call; both t04_generics_typeclass_overload_bug1.store(target: T: enum) [proc declared in t04_generics_typeclass_overload_bug1.nim(9, 6)] and t04_generics_typeclass_overload_bug1.store(target: T: tuple) [proc declared in t04_generics_typeclass_overload_bug1.nim(10, 6)] match for: ((int, int))" -""" - -proc store[T: enum](target: T) = discard -proc store[T: tuple](target: T) = discard - -proc aux1[T](obj: T) = store(obj) - -## aux1 can run and compile correctly -aux1((1, 2)) - -proc aux2[T](obj: T) = store[T](obj) - -## aux2 fails compilation -aux2((1, 2)) diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_conversion/readme.md b/tests/lang/s02_core/s02_procedures/t03_overload_core_conversion/readme.md deleted file mode 100644 index 761fb01f3f8..00000000000 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core_conversion/readme.md +++ /dev/null @@ -1,4 +0,0 @@ -This directory contains tests related to the implicit converters. It is -split into multiple files because converters cannot be declared in the -`block:` sections, so making a clean test (without any possibility of -triggering converters defined previously) requires multiple files. \ No newline at end of file diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim b/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim new file mode 100644 index 00000000000..8c60ea8041e --- /dev/null +++ b/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim @@ -0,0 +1,16 @@ +discard """ + description: ''' + Identical number of matches in each argument overload cateogory leads to + the ambiguous overload error. + ''' + errormsg: "ambiguous call; both t03_overload_core_ambiguous_fail.impl2(exact: uint8, conv: string) [proc declared in t03_overload_core_ambiguous_fail.nim(12, 6)] and t03_overload_core_ambiguous_fail.impl2(conv: string, exact: uint8) [proc declared in t03_overload_core_ambiguous_fail.nim(13, 6)] match for: (uint8, uint8)" +""" + +# TODO: this is a converter related test and should not be in s02_core + +converter toString(i8: uint8): string = $i8 + +proc impl2(exact: uint8, conv: string): string = "exact+conv" +proc impl2(conv: string, exact: uint8): string = "widen+widen" + +doAssert impl2(0u8, 0u8) == "exact+conv" \ No newline at end of file diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t03_overload_core_ambiguous_fail.nim b/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t03_overload_core_ambiguous_fail.nim deleted file mode 100644 index 62f6163a346..00000000000 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t03_overload_core_ambiguous_fail.nim +++ /dev/null @@ -1,15 +0,0 @@ -discard """ -description: ''' -Identical number of matches in each argument overload cateogory leads to the -ambiguous overload error. -''' -errormsg: "ambiguous call; both t03_overload_core_ambiguous_fail.impl2(exact: uint8, conv: string) [proc declared in t03_overload_core_ambiguous_fail.nim(12, 6)] and t03_overload_core_ambiguous_fail.impl2(conv: string, exact: uint8) [proc declared in t03_overload_core_ambiguous_fail.nim(13, 6)] match for: (uint8, uint8)" - -""" - -converter toString(i8: uint8): string = $i8 - -proc impl2(exact: uint8, conv: string): string = "exact+conv" -proc impl2(conv: string, exact: uint8): string = "widen+widen" - -doAssert impl2(0u8, 0u8) == "exact+conv" \ No newline at end of file diff --git a/tests/lang/s03_templating/readme.md b/tests/lang/s03_templating/readme.md index 1966669f9d8..79878a06018 100644 --- a/tests/lang/s03_templating/readme.md +++ b/tests/lang/s03_templating/readme.md @@ -2,4 +2,7 @@ Introduction of templating facilities into the language, primarily `template` routines, their calling, and interaction with overloads. Including `typed` and -`untyped` parameters and inline iterator support. \ No newline at end of file +`untyped` parameters and inline iterator support. + +TODO: +- figure out if `include` should be in this section or perhaps earlier \ No newline at end of file diff --git a/tests/lang/s04_parapoly/readme.md b/tests/lang/s04_parapoly/readme.md index c2d472c253e..b735a231f04 100644 --- a/tests/lang/s04_parapoly/readme.md +++ b/tests/lang/s04_parapoly/readme.md @@ -4,5 +4,7 @@ Support for Parametric Polymorphism (parapoly), or generics. This has implications for data types and procedures. This is exclusive of implicit generics/type parameters, but includes first class iterators. -TODO: confirm if first class iterators should be here, combined with an earlier - section, or separated into their own thing. \ No newline at end of file +TODO: +- confirm if first class iterators should be here, combined with another + section, or separated into their own thing. +- would this be better if we moved this whole section after module_system? \ No newline at end of file diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_non_distinct_typeclass_error.nim b/tests/lang/s04_parapoly/s03_overload/s01_generic_overload_errors/t01_non_distinct_typeclass_error.nim similarity index 84% rename from tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_non_distinct_typeclass_error.nim rename to tests/lang/s04_parapoly/s03_overload/s01_generic_overload_errors/t01_non_distinct_typeclass_error.nim index b7e4421bc8e..6e34ecc7671 100644 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_non_distinct_typeclass_error.nim +++ b/tests/lang/s04_parapoly/s03_overload/s01_generic_overload_errors/t01_non_distinct_typeclass_error.nim @@ -1,10 +1,9 @@ discard """ -description: ''' -Using user-defined typeclass in argument type works differently compared -to the explicitly written type alternatrives. -''' - -errormsg: "type mismatch: got " + description: ''' + Using user-defined typeclass in argument type works differently compared + to the explicitly written type alternatrives. + ''' + errormsg: "type mismatch: got " """ @@ -29,7 +28,6 @@ block: proc aliasedTypeAlts(a, b: distinct Typeclass) = discard aliasedTypeAlts(float(2.0), int(2)) - block: type Typeclass = int or float diff --git a/tests/lang/s04_parapoly/s03_overload/t01_generic_overloads.nim b/tests/lang/s04_parapoly/s03_overload/t01_generic_overloads.nim new file mode 100644 index 00000000000..0d6ec9fc1fe --- /dev/null +++ b/tests/lang/s04_parapoly/s03_overload/t01_generic_overloads.nim @@ -0,0 +1,83 @@ +discard """ + description: ''' + Specification for overloading with parametric polymorphism/generics + ''' +""" + +block most_specific_generic_wins: + ## If multiple overloaded procedures are present, most specific is + ## always selected. + + block qualifier: + ## `ref`, `ptr` and other type qualifiers are counted as a part of + ## the generic procedure definition. + + proc gen[T](x: var ref ref T): string = "var ref ref T" + proc gen[T](x: ref ref T): string = "ref ref T" + proc gen[T](x: ref T): string = "ref T" + proc gen[T](x: T): string = "T" + + var v: ref ref int = nil + doAssert gen(v) == "var ref ref T" + doAssert gen((ref ref int)(nil)) == "ref ref T" + doAssert gen((ref int)(nil)) == "ref T" + doAssert gen(nil) == "T" + + + # QUESTION - it is not possible to select less generic overload? + # doAssert gen[ref ref ref ref int](nil) == "ref T" + + block regular: + ## The rule also applied to regular generic types + proc gen[T](x: var seq[seq[T]]): string = "var seq seq T" + proc gen[T](x: seq[seq[T]]): string = "seq seq T" + proc gen[T](x: seq[T]): string = "seq T" + proc gen[T](x: T): string = "T" + + var v: seq[seq[int]] + doAssert gen(v) == "var seq seq T" + doAssert gen(newSeq[seq[int]]()) == "seq seq T" + doAssert gen(newSeq[int]()) == "seq T" + doAssert gen(nil) == "T" + +block generic_vs_subtype: + ## Generic overloading match comes before subtype relation match, so maybe code + ## like this would seem unexpected. + # + # Example taken from the https://github.com/nim-lang/Nim/issues/18314 + # + type + A = ref object of RootObj + B = ref object of A + C = ref object of B + + block regular_procs: + proc impl[T: A](a: T): string = "matched generic" + proc impl(b: B): string = "matched subtype B" + + ## subtype vs generic - wins generic + doAssert impl(C()) == "matched generic" + + ## generic vs exact match - wins exact match + doAssert impl(B()) == "matched subtype B" + +block subtype_constaints_for_generic: + ## When subtype is used as a constraint for the generic parameter it + ## functions the same way as if it was written directly in the argument. + + type + A = ref object of RootObj + B1 = ref object of A + B2 = ref object of A + + proc impl[T](a: T): string = "T" + proc impl[T: A](a: T): string = "A" + proc impl[T: B1](a: T): string = "B1" + proc impl[T: B2](a: T): string = "B2" + proc impl[T: B1 | B2](a: T): string = "B1|B2" + + doAssert impl(B1()) == "B1" + doAssert impl(B2()) == "B2" + + ## Note that `B1 | B2` is not reported as an ambiguous overload since constaints + ## with alternatives have a lower precedence compared to the simple `SomeType`. diff --git a/tests/lang/s04_parapoly/s03_overload/t02_varargs_polymorphic_generic.nim b/tests/lang/s04_parapoly/s03_overload/t02_varargs_polymorphic_generic.nim new file mode 100644 index 00000000000..d4882e179aa --- /dev/null +++ b/tests/lang/s04_parapoly/s03_overload/t02_varargs_polymorphic_generic.nim @@ -0,0 +1,55 @@ +discard """ + description: ''' + `varargs` is defined to behave the same way as routine with multiple + arguments, which means derived objects should correctly pass a slice/ptr to + the routine. + + When a `varargs` routine is called, temporary array with values is + constructed, before being passed to the called procedure. If derived object + is passed, correct `.Sup` must be used to achieve desired behavior. + ''' + knownIssue: ''' + passing derived generic types via varargs raises an "invalid object + assignment" exception. + ''' +""" + +var invalidAssings: seq[string] + +block: + type + Base[T] = object of RootObj + value: T + Derived1[T] = object of Base[T] + Derived2[T] = object of Base[T] + + + proc implRegular[T](a, b, c: Base[T]): string = + result.add $a.value + result.add $b.value + result.add $c.value + + proc implVarargs[T](x: varargs[Base[T]]): string = + discard + # result = "" + # for c in x: + # result.add $c.value + + doAssert implRegular( + Derived2[int](value: 2), + Derived1[int](value: 4), + Base[int](value: 3) + ) == "243", "Passing subtypes using regular arguments works correctly" + + try: + doAssert implVarargs( + Derived2[int](value: 2), + Derived1[int](value: 4), + Base[int](value: 3) + ) == "243", "Passing subtypes via varargs must work the same way as mutliple arguments" + except ObjectAssignmentdefect: + invalidAssings.add "Derived1, Derived, Base" + +doAssert invalidAssings.len == 0, "Failed object assignment for " & + $invalidAssings.len & " cases - " & + $invalidAssings diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t04_generic_and_subtype_matches_widest.nim b/tests/lang/s04_parapoly/s03_overload/t04_generic_and_subtype_matches_widest.nim similarity index 100% rename from tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t04_generic_and_subtype_matches_widest.nim rename to tests/lang/s04_parapoly/s03_overload/t04_generic_and_subtype_matches_widest.nim diff --git a/tests/lang/s04_parapoly/s04_typeclass/readme.md b/tests/lang/s04_parapoly/s04_typeclass/readme.md new file mode 100644 index 00000000000..d1ff7dd2752 --- /dev/null +++ b/tests/lang/s04_parapoly/s04_typeclass/readme.md @@ -0,0 +1,7 @@ +# What Belongs Here? + +Support for 'typeclasses' which are, at the time of writing, underspecified. +They are broad classes of types, such as `object`, `tuple`, `enum`, etc, and +can be thought of as a generalization in the type system over their more +specific counter-parts. Typeclasses revolved around implicit generics and +type parameter constraints. \ No newline at end of file diff --git a/tests/lang/s02_core/s01_user_defined_data_types/t07_typeclass.nim b/tests/lang/s04_parapoly/s04_typeclass/t01_typeclass.nim similarity index 84% rename from tests/lang/s02_core/s01_user_defined_data_types/t07_typeclass.nim rename to tests/lang/s04_parapoly/s04_typeclass/t01_typeclass.nim index e4a0fca25f2..cdceb4314b2 100644 --- a/tests/lang/s02_core/s01_user_defined_data_types/t07_typeclass.nim +++ b/tests/lang/s04_parapoly/s04_typeclass/t01_typeclass.nim @@ -4,6 +4,9 @@ PLACEHOLDER ''' """ +# TODO: this likely needs to move to a later section and not be a part of basic +# parametric polymorphism. + block builtin_typeclasses: block object_class: type Obj = object diff --git a/tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim b/tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim new file mode 100644 index 00000000000..5e73dee28a9 --- /dev/null +++ b/tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim @@ -0,0 +1,23 @@ +discard """ + description: ''' + Generic constraints for enum and tuple fail to resolve (ambigouus call) + if explicit generic parameter is used. When called without explicit + parameter (type inferred from the argument), code compiles correctly. + ''' + knownIssue: "enum/tuple generic constraint fails to resolve (ambiguous)" +""" + +# once fixed combine with type class specifications + +proc store[T: enum](target: T) = discard +proc store[T: tuple](target: T) = discard + +proc aux1[T](obj: T) = store(obj) + +## aux1 can run and compile correctly +aux1((1, 2)) + +proc aux2[T](obj: T) = store[T](obj) + +## aux2 fails compilation +aux2((1, 2)) diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t05_typeclass_constaint_is_ambiguous.nim b/tests/lang/s04_parapoly/s04_typeclass/t03_typeclasses_bug_constraint_is_ambiguous.nim similarity index 62% rename from tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t05_typeclass_constaint_is_ambiguous.nim rename to tests/lang/s04_parapoly/s04_typeclass/t03_typeclasses_bug_constraint_is_ambiguous.nim index 3dc6dd838a9..d32567f88ac 100644 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core_bugs/t05_typeclass_constaint_is_ambiguous.nim +++ b/tests/lang/s04_parapoly/s04_typeclass/t03_typeclasses_bug_constraint_is_ambiguous.nim @@ -1,11 +1,12 @@ discard """ -description: ''' -Moving argument type constaint into separate generic parameter causes -and "ambiguous overload" error. -''' -knownIssue: "generic parameter with alt constraint is ambiguous" -knownIssue: "https://github.com/nim-lang/Nim/issues/6840" - + description: ''' + Moving an argument type constraint into a separate generic parameter causes + and "ambiguous overload" error. + ''' + knownIssue: ''' + generic parameter with alternate constraint is ambiguous, see: + https://github.com/nim-lang/Nim/issues/6840 + ''' """ diff --git a/tests/lang/s04_parapoly/s05_converters/readme.md b/tests/lang/s04_parapoly/s05_converters/readme.md new file mode 100644 index 00000000000..a286adf74c3 --- /dev/null +++ b/tests/lang/s04_parapoly/s05_converters/readme.md @@ -0,0 +1,4 @@ +# What Belongs Here? + +Converter related tests which involve generics, since converters are top level +and act over the whole module, each test is broken up into several files. \ No newline at end of file diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_conversion/t01_generic_converter.nim b/tests/lang/s04_parapoly/s05_converters/t01_generic_converter.nim similarity index 100% rename from tests/lang/s02_core/s02_procedures/t03_overload_core_conversion/t01_generic_converter.nim rename to tests/lang/s04_parapoly/s05_converters/t01_generic_converter.nim diff --git a/tests/lang/s05_pragmas/readme.md b/tests/lang/s05_pragmas/readme.md new file mode 100644 index 00000000000..835fbb07f14 --- /dev/null +++ b/tests/lang/s05_pragmas/readme.md @@ -0,0 +1,5 @@ +# What Belongs Here? + +This is a poorly named section, it might be best to combine this section with +others. Covering any arbitrary pragma doesn't make sense, instead perhaps only +the application of metadata, such as annotations and possibly effects. \ No newline at end of file diff --git a/tests/lang/s02_core/s02_procedures/t01_regular_procs_dot_operators.nim b/tests/lang/s10_experimental/t01_regular_procs_dot_operators.nim similarity index 78% rename from tests/lang/s02_core/s02_procedures/t01_regular_procs_dot_operators.nim rename to tests/lang/s10_experimental/t01_regular_procs_dot_operators.nim index fbb1d90200c..49d702ac2c5 100644 --- a/tests/lang/s02_core/s02_procedures/t01_regular_procs_dot_operators.nim +++ b/tests/lang/s10_experimental/t01_regular_procs_dot_operators.nim @@ -2,7 +2,7 @@ discard """ description: ''' Specification of the experimental dot operators feature ''' -cmd: "nim $target -r -d:nimPreviewDotLikeOps $options $file" +matrix: "-d:nimPreviewDotLikeOps" """ {.experimental: "dotOperators".} From 8bf496b98291f554eea4431a64b88f58098b0568 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Thu, 8 Feb 2024 15:26:20 -0800 Subject: [PATCH 05/14] minor clean-up in `generics/tarc_misc` the test still needs further clarification and can likely be reduced --- tests/lang_callable/generics/tarc_misc.nim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/lang_callable/generics/tarc_misc.nim b/tests/lang_callable/generics/tarc_misc.nim index 5c494b06d7b..457b7633642 100644 --- a/tests/lang_callable/generics/tarc_misc.nim +++ b/tests/lang_callable/generics/tarc_misc.nim @@ -1,10 +1,9 @@ discard """ - matrix: "--gc:arc" output: '''''' """ -# bug #13519 -# Not necessarily just arc, we can just more strict about proc type conversions +# bug: https://github.com/nim-lang/Nim/issues/13519 +# TODO: rename to something about proc type strictness var unrelated: seq[proc() {.closure, gcsafe.}] From d55ff052f9eabbe474c42e4494b3b5a4e0cf0db0 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Thu, 8 Feb 2024 15:27:24 -0800 Subject: [PATCH 06/14] restore commented out tests --- tests/lang_callable/generics/tgeneric_typeclass_alias.nim | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/lang_callable/generics/tgeneric_typeclass_alias.nim b/tests/lang_callable/generics/tgeneric_typeclass_alias.nim index 2d5bbc65e18..43e88c97151 100644 --- a/tests/lang_callable/generics/tgeneric_typeclass_alias.nim +++ b/tests/lang_callable/generics/tgeneric_typeclass_alias.nim @@ -157,7 +157,6 @@ block: doAssert(foo4(x) == 4) doAssert(foo5(x) == 5) - #[ XXX These still fail block: var x: FooObj2[float] doAssert(foo0(x) == 0) @@ -166,5 +165,3 @@ block: doAssert(foo3(x) == 3) doAssert(foo4(x) == 4) doAssert(foo5(x) == 5) - ]# - From 784f91a8e7cfaf296b2f2e3fedc8457ea4f572fe Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Thu, 8 Feb 2024 15:28:09 -0800 Subject: [PATCH 07/14] tests use `knownIssue.vm` properly --- tests/lang_callable/generics/tgeneric0.nim | 4 +--- tests/lang_callable/generics/tgeneric3.nim | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/tests/lang_callable/generics/tgeneric0.nim b/tests/lang_callable/generics/tgeneric0.nim index c8c471ac54d..a8f990bbc03 100644 --- a/tests/lang_callable/generics/tgeneric0.nim +++ b/tests/lang_callable/generics/tgeneric0.nim @@ -1,5 +1,5 @@ discard """ - target: "!vm" + knownIssue.vm: "it seems to get stuck; needs a deeper dive" output: ''' 100 0 @@ -9,8 +9,6 @@ float32 ''' """ -# disabled on VM: it seems to get stuck; needs a deeper dive (knownIssue) - import std/tables diff --git a/tests/lang_callable/generics/tgeneric3.nim b/tests/lang_callable/generics/tgeneric3.nim index d7eec02bc79..388a0356b89 100644 --- a/tests/lang_callable/generics/tgeneric3.nim +++ b/tests/lang_callable/generics/tgeneric3.nim @@ -1,5 +1,5 @@ discard """ -target: "!vm" +knownIssue.vm: "it seems to get stuck; needs a deeper dive" output: ''' 312 1000000 @@ -9,8 +9,6 @@ output: ''' ''' """ -# disabled on VM: it seems to get stuck; needs a deeper dive (knownIssue) - import std/strutils type @@ -28,7 +26,6 @@ type left: PNode[T,D] count: int32 - RPath[T,D] = tuple[ Xi: int, Nd: PNode[T,D] ] From 4a7e4e6d5dc53493c1d1f016ef91368e39d94f11 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Thu, 8 Feb 2024 15:30:53 -0800 Subject: [PATCH 08/14] note broken default param for generic param type This is a dumb 'feature', it doesn't make sense and should never pass. It clearly demonstrates a bug where we equate `any` with `untyped`. Mark the test as a `knownIssue` so we know when it starts failing again. --- tests/lang_callable/generics/tgenerictmpl2.nim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/lang_callable/generics/tgenerictmpl2.nim b/tests/lang_callable/generics/tgenerictmpl2.nim index 2efb000b307..d25a2a78305 100644 --- a/tests/lang_callable/generics/tgenerictmpl2.nim +++ b/tests/lang_callable/generics/tgenerictmpl2.nim @@ -1,4 +1,15 @@ discard """ +action: reject +knownIssue: "this is not at all how generics + default params should work" +""" + +# This is not a "feature", it's completely broken that this works, `999`, the +# default parameter, does not satisfy all `T: any`. Nor can `T` be "inferred" +# as `int` in the default case as one can specify `T` breaking the default. +# This should plainly be illegal, as `T` is not equivalent to `untyped`. + +#[ +# old output that should _never_ have worked output: '''1 1 1 @@ -7,7 +18,7 @@ discard """ 999 999 2''' -""" +]# # test if we can pass explicit generic arguments to generic templates # based on bug report #3496 From 45070db84e3752f679c5b4d8095f5e6fb10e3a9a Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Fri, 9 Feb 2024 12:11:32 -0800 Subject: [PATCH 09/14] fix error message in test --- .../t01_overload_core_ambiguous_fail.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim b/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim index 8c60ea8041e..bdaca2b7661 100644 --- a/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim +++ b/tests/lang/s02_core/s02_procedures/t03_overload_core_errors/t01_overload_core_ambiguous_fail.nim @@ -1,9 +1,9 @@ discard """ description: ''' - Identical number of matches in each argument overload cateogory leads to - the ambiguous overload error. + Identical number of matches in each argument overload category leads to an + ambiguous overload error. ''' - errormsg: "ambiguous call; both t03_overload_core_ambiguous_fail.impl2(exact: uint8, conv: string) [proc declared in t03_overload_core_ambiguous_fail.nim(12, 6)] and t03_overload_core_ambiguous_fail.impl2(conv: string, exact: uint8) [proc declared in t03_overload_core_ambiguous_fail.nim(13, 6)] match for: (uint8, uint8)" + errormsg: "ambiguous call; both t01_overload_core_ambiguous_fail.impl2(exact: uint8, conv: string) [proc declared in t01_overload_core_ambiguous_fail.nim(13, 6)] and t01_overload_core_ambiguous_fail.impl2(conv: string, exact: uint8) [proc declared in t01_overload_core_ambiguous_fail.nim(14, 6)] match for: (uint8, uint8)" """ # TODO: this is a converter related test and should not be in s02_core From daeb5109b9a5fdffe0ccbbad8e06cafa170393b2 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Fri, 9 Feb 2024 12:11:59 -0800 Subject: [PATCH 10/14] remove known issues from tests that now work --- .../t01_varargs_does_not_support_polymorphic.nim | 4 ---- tests/lang_callable/generics/tgeneric0.nim | 1 - 2 files changed, 5 deletions(-) diff --git a/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim b/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim index d474579485e..95a443b967c 100644 --- a/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim +++ b/tests/lang/s02_core/s02_procedures/t02_argument_passing_bugs/t01_varargs_does_not_support_polymorphic.nim @@ -11,7 +11,6 @@ being passed to the called procedure. If derived object is passed, correct `.Sup be used to achieve desired behavior. ''' -knownIssue: "varargs cannot pass polymorphic derived types" """ var invalidAssings: seq[string] @@ -33,18 +32,15 @@ block regular_types: try: test(Base()) - except ObjectAssignmentDefect: invalidAssings.add "Base()" try: test(Base(), Derived1()) - except ObjectAssignmentDefect: invalidAssings.add "Base(), Derived1()" try: test(Derived1(), Derived2()) - except ObjectAssignmentDefect: invalidAssings.add "Derived1(), Derived2()" diff --git a/tests/lang_callable/generics/tgeneric0.nim b/tests/lang_callable/generics/tgeneric0.nim index a8f990bbc03..795af2b8daa 100644 --- a/tests/lang_callable/generics/tgeneric0.nim +++ b/tests/lang_callable/generics/tgeneric0.nim @@ -1,5 +1,4 @@ discard """ - knownIssue.vm: "it seems to get stuck; needs a deeper dive" output: ''' 100 0 From 02054ade3e7b7e9ae58d3631e6caeb4f45cae3ad Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Fri, 9 Feb 2024 12:16:12 -0800 Subject: [PATCH 11/14] remove known issue from tests that now work --- ...bug_tuple_matches_for_enum_typeclass_constraint.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim b/tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim index 5e73dee28a9..f141d99fa66 100644 --- a/tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim +++ b/tests/lang/s04_parapoly/s04_typeclass/t02_typeclasses_bug_tuple_matches_for_enum_typeclass_constraint.nim @@ -1,13 +1,13 @@ discard """ description: ''' - Generic constraints for enum and tuple fail to resolve (ambigouus call) - if explicit generic parameter is used. When called without explicit - parameter (type inferred from the argument), code compiles correctly. + Regression test where generic constraints for enum and tuple fail to + resolve (ambigouus call) if an explicit generic parameter is used. When + called without an explicit parameter (the type is inferred from the + argument), code compiles correctly. ''' - knownIssue: "enum/tuple generic constraint fails to resolve (ambiguous)" """ -# once fixed combine with type class specifications +# TODO: once fixed combine with type class specifications?? proc store[T: enum](target: T) = discard proc store[T: tuple](target: T) = discard From 25ddd60f46bcb0451aa571fd84dd811656b21ed8 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Fri, 16 Feb 2024 13:59:13 -0800 Subject: [PATCH 12/14] disable test on vm, as it's too slow for now --- tests/lang_callable/generics/tgeneric3.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/lang_callable/generics/tgeneric3.nim b/tests/lang_callable/generics/tgeneric3.nim index 388a0356b89..2f5ee36726f 100644 --- a/tests/lang_callable/generics/tgeneric3.nim +++ b/tests/lang_callable/generics/tgeneric3.nim @@ -1,5 +1,6 @@ discard """ -knownIssue.vm: "it seems to get stuck; needs a deeper dive" +targets: "!vm" +knownIssue.vm: "very slow on the vm" output: ''' 312 1000000 From 3c88bbb2cf4f026304a72e87f38fcecf61353fd8 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Fri, 16 Feb 2024 15:08:54 -0800 Subject: [PATCH 13/14] change `assert` to `doAssert` --- .../generics/trecursivegenerics.nim | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/lang_callable/generics/trecursivegenerics.nim b/tests/lang_callable/generics/trecursivegenerics.nim index 1b152b06359..6116bf62e4f 100644 --- a/tests/lang_callable/generics/trecursivegenerics.nim +++ b/tests/lang_callable/generics/trecursivegenerics.nim @@ -7,13 +7,13 @@ block: # Replicates #18728 Trinary[A, B, C] = ref object next: Trinary[B, C, A] - assert typeof(FlipFlop[int, string]().next) is FlipFlop[string, int] - assert typeof(FlipFlop[string, int]().next) is FlipFlop[int, string] - assert typeof(Trinary[int, float, string]().next) is Trinary[float, string, int] - assert typeof(Trinary[int, float, string]().next.next) is Trinary[string, int, float] + doAssert typeof(FlipFlop[int, string]().next) is FlipFlop[string, int] + doAssert typeof(FlipFlop[string, int]().next) is FlipFlop[int, string] + doAssert typeof(Trinary[int, float, string]().next) is Trinary[float, string, int] + doAssert typeof(Trinary[int, float, string]().next.next) is Trinary[string, int, float] var a = FlipFlop[int, string](val: 100, next: FlipFlop[string, int](val: "Hello")) - assert a.val == 100 - assert a.next.val == "Hello" + doAssert a.val == 100 + doAssert a.next.val == "Hello" block: # 18838 type @@ -33,7 +33,9 @@ block: # 18838 let link = newDoublyLinkedNode(Item[Box]()) -import lists + doAssert link is DoublyLinkedNode[Item[Box]] + +import std/lists block: type Box = object @@ -45,6 +47,8 @@ block: let link = newDoublyLinkedNode( Item[Box]() ) + doAssert link is DoublyLinkedNode[Item[Box]] + block: #18897 type SkipListObj[T] = object From 9217c389d4bf627a8553f32461973cb6ca3ec599 Mon Sep 17 00:00:00 2001 From: Saem Ghani Date: Fri, 16 Feb 2024 15:09:03 -0800 Subject: [PATCH 14/14] add inverse tests for generic "alias" --- tests/types/tisopr.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim index e82b97a155c..e68803d2dfd 100644 --- a/tests/types/tisopr.nim +++ b/tests/types/tisopr.nim @@ -102,6 +102,7 @@ block: doAssert Foo2 is Foo2 doAssert Foo2 isnot Bar doAssert Foo[int,float] is Foo2[int,float] + doAssert Foo2[int,float] is Foo[int,float] # other doAssert Foo[int,float] isnot Foo2[float,float]