Skip to content

Commit 105ab31

Browse files
committed
[Parse] Re-allow prefix operators containing /
1 parent a1e138b commit 105ab31

File tree

4 files changed

+4
-14
lines changed

4 files changed

+4
-14
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ ERROR(forbidden_extended_escaping_string,none,
9494
ERROR(regex_literal_parsing_error,none,
9595
"%0", (StringRef))
9696

97-
ERROR(prefix_slash_not_allowed,none,
98-
"prefix operator may not contain '/'", ())
99-
10097
//------------------------------------------------------------------------------
10198
// MARK: Lexer diagnostics
10299
//------------------------------------------------------------------------------

lib/Parse/ParseDecl.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8541,13 +8541,6 @@ Parser::parseDeclOperator(ParseDeclOptions Flags, DeclAttributes &Attributes) {
85418541
Tok.getRawText().front() == '!'))
85428542
diagnose(Tok, diag::postfix_operator_name_cannot_start_with_unwrap);
85438543

8544-
// Prefix operators may not contain the `/` character when `/.../` regex
8545-
// literals are enabled.
8546-
if (Context.LangOpts.EnableBareSlashRegexLiterals) {
8547-
if (Attributes.hasAttribute<PrefixAttr>() && Tok.getText().contains("/"))
8548-
diagnose(Tok, diag::prefix_slash_not_allowed);
8549-
}
8550-
85518544
// A common error is to try to define an operator with something in the
85528545
// unicode plane considered to be an operator, or to try to define an
85538546
// operator like "not". Analyze and diagnose this specifically.

test/StringProcessing/Frontend/enable-flag.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// REQUIRES: swift_in_compiler
66

7-
prefix operator / // expected-error {{prefix operator may not contain '/'}}
7+
prefix operator /
88

99
_ = /x/
1010
_ = #/x/#

test/StringProcessing/Parse/forward-slash-regex.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// REQUIRES: swift_in_compiler
33
// REQUIRES: concurrency
44

5-
prefix operator / // expected-error {{prefix operator may not contain '/'}}
6-
prefix operator ^/ // expected-error {{prefix operator may not contain '/'}}
7-
prefix operator /^/ // expected-error {{prefix operator may not contain '/'}}
5+
prefix operator /
6+
prefix operator ^/
7+
prefix operator /^/
88

99
prefix operator !!
1010
prefix func !! <T>(_ x: T) -> T { x }

0 commit comments

Comments
 (0)