Skip to content

Commit 990214a

Browse files
authored
Fix module packs in unpack expressions (#289)
Allow first-class module packs with module type annotations inside unpack expressions, e.g. `unpack(module(Cleanup): PipelineStep with type state = t)`. Close #288
1 parent 5c71beb commit 990214a

5 files changed

Lines changed: 42 additions & 2 deletions

File tree

grammar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export default grammar({
218218
optional($.module_type_annotation),
219219
),
220220
seq($.call_expression, optional($.module_type_annotation)),
221+
seq($.module_pack, optional($.module_type_annotation)),
221222
$.extension_expression,
222223
),
223224
")",

src/grammar.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parser.c

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/corpus/modules.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ module(
245245
)
246246
module(SomeFunctor(unpack(x)))
247247

248+
module M = unpack(module(Cleanup): PipelineStep with type state = t)
249+
248250
module T = unpack(foo: T)
249251

250252
module S = unpack(foo: T with type t = a)
@@ -288,6 +290,18 @@ module T3 = unpack(make(): T with type t = int)
288290
(arguments
289291
(module_unpack
290292
(value_identifier))))))
293+
(module_declaration
294+
(module_binding
295+
(module_identifier)
296+
(module_unpack
297+
(module_pack
298+
(module_identifier))
299+
(module_type_annotation
300+
(module_type_constraint
301+
(module_identifier)
302+
(constrain_type
303+
(type_identifier)
304+
(type_identifier)))))))
291305
(module_declaration
292306
(module_binding
293307
(module_identifier)

0 commit comments

Comments
 (0)