Skip to content

Commit 3184459

Browse files
aspeddroclaude
andauthored
Fix module_unpack to allow type annotation on call expressions (#270)
Adds optional `module_type_annotation` after `call_expression` inside `module_unpack`, so `unpack(make(): T)` parses correctly. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1e04f06 commit 3184459

4 files changed

Lines changed: 49 additions & 6 deletions

File tree

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ module.exports = grammar({
205205
),
206206
optional($.module_type_annotation),
207207
),
208-
$.call_expression,
208+
seq($.call_expression, optional($.module_type_annotation)),
209209
$.extension_expression,
210210
),
211211
")",

src/grammar.json

Lines changed: 19 additions & 2 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: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ module S = unpack(Mod.read(v))
253253

254254
module S = unpack(%extension(payload))
255255

256+
module T2 = unpack(make(): T)
257+
258+
module T3 = unpack(make(): T with type t = int)
259+
256260
--------------------------------------------------------------------------------
257261

258262
(source_file
@@ -319,7 +323,29 @@ module S = unpack(%extension(payload))
319323
(extension_expression
320324
(extension_identifier)
321325
(expression_statement
322-
(value_identifier)))))))
326+
(value_identifier))))))
327+
(module_declaration
328+
(module_binding
329+
(module_identifier)
330+
(module_unpack
331+
(call_expression
332+
(value_identifier)
333+
(arguments))
334+
(module_type_annotation
335+
(module_identifier)))))
336+
(module_declaration
337+
(module_binding
338+
(module_identifier)
339+
(module_unpack
340+
(call_expression
341+
(value_identifier)
342+
(arguments))
343+
(module_type_annotation
344+
(module_type_constraint
345+
(module_identifier)
346+
(constrain_type
347+
(type_identifier)
348+
(type_identifier))))))))
323349

324350
================================================================================
325351
Functor definition

0 commit comments

Comments
 (0)