Skip to content

Allow literal types to be operands of an infix type #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PREC = {

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, scala_scala/src/library/: 100.00%, expected at least 100%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, scala_scala/src/compiler/: 96.65%, expected at least 96%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, dotty/compiler/: 83.62%, expected at least 83%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, lila/modules/: 84.81%, expected at least 84%

Check notice on line 1 in grammar.js

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

ok, complexity of the most complex definition Warning:: unnecessary, lower than the allowed ceiling 1400
comment: 1,
using_directive: 2,
control: 1,
Expand Down Expand Up @@ -875,7 +875,7 @@
_infix_type_choice: $ =>
prec.left(
PREC.infix,
choice($.compound_type, $.infix_type, $._annotated_type),
choice($.compound_type, $.infix_type, $._annotated_type, $.literal_type),
),

infix_type: $ =>
Expand Down
33 changes: 32 additions & 1 deletion test/corpus/types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -623,4 +623,35 @@ class A[
(identifier)
(upper_bound
(type_identifier))
(type_identifier)))))
(type_identifier)))))

================================================================================
Union and Intersection Types (Scala 3)
================================================================================

type A = Foo | Bar & Buz
type B = "foo" | "bar" & "buz"

--------------------------------------------------------------------------------
(compilation_unit
(type_definition
(type_identifier)
(infix_type
(infix_type
(type_identifier)
(operator_identifier)
(type_identifier))
(operator_identifier)
(type_identifier)))
(type_definition
(type_identifier)
(infix_type
(infix_type
(literal_type
(string))
(operator_identifier)
(literal_type
(string)))
(operator_identifier)
(literal_type
(string)))))