You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Unify macro expansion parsing logic between MacroExpansionExpr and
MacroExpansionDecl
* Diagnose whitespace between '#' and the macro name
* Diagnose keyword as a macro name
let _:Int= #public() // expected-error {{keyword 'public' cannot be used as an identifier here}} expected-note {{if this name is unavoidable, use backticks to escape it}}
Copy file name to clipboardExpand all lines: test/Parse/macro_decl.swift
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -46,3 +46,11 @@ func test() {
46
46
@CustomAttr
47
47
isolated #someFunc
48
48
}
49
+
50
+
public # someFunc // expected-error {{extraneous whitespace between '#' and macro name is not permitted}} {{9-10=}}
51
+
52
+
struct S {
53
+
# someFunc // expected-error {{extraneous whitespace between '#' and macro name is not permitted}} {{4-5=}}
54
+
#class // expected-error {{keyword 'class' cannot be used as an identifier here}} expected-note {{if this name is unavoidable, use backticks to escape it}} {{4-9=`class`}}
55
+
# struct Inner {} // expected-error {{expected a macro identifier for a pound literal declaration}} expected-error {{consecutive declarations on a line}}
Copy file name to clipboardExpand all lines: test/Parse/macro_expr.swift
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -35,3 +35,17 @@ _ = #another {
35
35
36
36
// expected-error @+1 {{expected a macro identifier for a pound literal expression}}
37
37
_ = #()
38
+
39
+
do{
40
+
_ = # // expected-error {{expected a macro identifier for a pound literal expression}}
41
+
name()
42
+
}
43
+
do{
44
+
_ = # macro() // expected-error {{extraneous whitespace between '#' and macro name is not permitted}} {{8-9=}}
45
+
}
46
+
do{
47
+
_ = #public() // expected-error {{keyword 'public' cannot be used as an identifier here}} expected-note {{if this name is unavoidable, use backticks to escape it}} {{8-14=`public`}}
48
+
}
49
+
do{
50
+
_ = # public() // expected-error {{expected a macro identifier for a pound literal expression}}
0 commit comments