Skip to content

Commit 0dc16cf

Browse files
authored
Merge pull request #409 from susliko/literals-and-infix-types
Allow literal types to be operands of an infix type
2 parents c694c1b + 39705e7 commit 0dc16cf

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ module.exports = grammar({
875875
_infix_type_choice: $ =>
876876
prec.left(
877877
PREC.infix,
878-
choice($.compound_type, $.infix_type, $._annotated_type),
878+
choice($.compound_type, $.infix_type, $._annotated_type, $.literal_type),
879879
),
880880

881881
infix_type: $ =>

test/corpus/types.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,4 +623,35 @@ class A[
623623
(identifier)
624624
(upper_bound
625625
(type_identifier))
626-
(type_identifier)))))
626+
(type_identifier)))))
627+
628+
================================================================================
629+
Union and Intersection Types (Scala 3)
630+
================================================================================
631+
632+
type A = Foo | Bar & Buz
633+
type B = "foo" | "bar" & "buz"
634+
635+
--------------------------------------------------------------------------------
636+
(compilation_unit
637+
(type_definition
638+
(type_identifier)
639+
(infix_type
640+
(infix_type
641+
(type_identifier)
642+
(operator_identifier)
643+
(type_identifier))
644+
(operator_identifier)
645+
(type_identifier)))
646+
(type_definition
647+
(type_identifier)
648+
(infix_type
649+
(infix_type
650+
(literal_type
651+
(string))
652+
(operator_identifier)
653+
(literal_type
654+
(string)))
655+
(operator_identifier)
656+
(literal_type
657+
(string)))))

0 commit comments

Comments
 (0)