From a76c359655ffe895e3f1c13269599a19a1f72942 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 4 Dec 2022 12:12:31 -0300 Subject: [PATCH 1/2] fix: support aliasing type for generic-type --- grammar.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/grammar.js b/grammar.js index 8448eb8..88d95c7 100644 --- a/grammar.js +++ b/grammar.js @@ -424,10 +424,11 @@ module.exports = grammar({ ), - generic_type: $ => seq( + generic_type: $ => prec.left(seq( $._type_identifier, - $.type_arguments - ), + $.type_arguments, + optional($.as_aliasing_type) + )), type_arguments: $ => seq( '<', From 6577e2f80140ee10018b484ea81531a5055a44d5 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 4 Dec 2022 12:27:55 -0300 Subject: [PATCH 2/2] add tests --- test/corpus/type_declarations.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/corpus/type_declarations.txt b/test/corpus/type_declarations.txt index 5335f1e..34b6f15 100644 --- a/test/corpus/type_declarations.txt +++ b/test/corpus/type_declarations.txt @@ -349,6 +349,7 @@ Generic type t<'a, 'b> = (array<'a>, array<'b>) type t = result<(), string> +type t<'a> = generic<'a> as 's --- @@ -365,7 +366,15 @@ type t = result<(), string> (type_identifier) (type_arguments (unit) - (type_identifier))))) + (type_identifier)))) + + (type_declaration + (type_identifier) + (type_parameters (type_identifier)) + (generic_type + (type_identifier) + (type_arguments (type_identifier)) + (as_aliasing_type (type_identifier))))) =========================================== Recursive