Skip to content

Commit 2c459cd

Browse files
committed
Only allow _numeric_ literals in typed patterns
1 parent 4baaa50 commit 2c459cd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2810,7 +2810,8 @@ object Parsers {
28102810
else Nil
28112811

28122812
/** Pattern1 ::= PatVar Ascription
2813-
* | SimpleLiteral Ascription
2813+
* | [‘-’] integerLiteral Ascription
2814+
* | [‘-’] floatingPointLiteral Ascription
28142815
* | Pattern2
28152816
*/
28162817
def pattern1(location: Location = Location.InPattern): Tree =

docs/_docs/internals/syntax.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ TypeCaseClause ::= ‘case’ (InfixType | ‘_’) ‘=>’ Type [semi]
319319
320320
Pattern ::= Pattern1 { ‘|’ Pattern1 } Alternative(pats)
321321
Pattern1 ::= PatVar ‘:’ RefinedType Bind(name, Typed(Ident(wildcard), tpe))
322-
| SimpleLiteral ‘:’ RefinedType Typed(pat, tpe)
322+
| [‘-’] integerLiteral ‘:’ RefinedType Typed(pat, tpe)
323+
| [‘-’] floatingPointLiteral ‘:’ RefinedType Typed(pat, tpe)
323324
| Pattern2
324325
Pattern2 ::= [id ‘@’] InfixPattern [‘*’] Bind(name, pat)
325326
InfixPattern ::= SimplePattern { id [nl] SimplePattern } InfixOp(pat, op, pat)

0 commit comments

Comments
 (0)