File: multiline_errors.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (199 lines) | stat: -rw-r--r-- 7,036 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// RUN: %target-typecheck-verify-swift

import Swift

// ===---------- Multiline --------===

// expecting at least 4 columns of leading indentation
_ = """
    Eleven
  Mu
    """ // expected-error@-1{{insufficient indentation of line in multi-line string literal}}
        // expected-note@-1{{should match space here}}
        // expected-note@-3{{change indentation of this line to match closing delimiter}} {{3-3=  }}

// expecting at least 4 columns of leading indentation
_ = """
    Eleven
   Mu
    """ // expected-error@-1{{insufficient indentation of line in multi-line string literal}}
        // expected-note@-1{{should match space here}}
        // expected-note@-3{{change indentation of this line to match closing delimiter}} {{4-4= }}

// \t is not the same as an actual tab for de-indentation
_ = """
	Twelve
\tNu
	""" // expected-error@-1{{insufficient indentation of line in multi-line string literal}}
      // expected-note@-1{{should match tab here}}
      // expected-note@-3{{change indentation of this line to match closing delimiter}} {{1-1=	}}

_ = """
    \(42
)
    """ // expected-error@-1{{insufficient indentation of line in multi-line string literal}}
        // expected-note@-1{{should match space here}}
        // expected-note@-3{{change indentation of this line to match closing delimiter}} {{1-1=    }}

_ = """
    Foo
\
    Bar 
    """ // expected-error@-2{{insufficient indentation of line in multi-line string literal}}
        // expected-note@-1{{should match space here}}
        // expected-note@-4{{change indentation of this line to match closing delimiter}} {{1-1=    }}

// a tab is not the same as multiple spaces for de-indentation
_ = """
  Thirteen
	Xi
  """ // expected-error@-1{{unexpected tab in indentation of line in multi-line string literal}}
      // expected-note@-1{{should match space here}}
      // expected-note@-3{{change indentation of this line to match closing delimiter}} {{1-2=  }}

// a tab is not the same as multiple spaces for de-indentation
_ = """
    Fourteen
  	Pi
    """ // expected-error@-1{{unexpected tab in indentation of line in multi-line string literal}}
        // expected-note@-1{{should match space here}}
        // expected-note@-3{{change indentation of this line to match closing delimiter}} {{3-4=  }}

// multiple spaces are not the same as a tab for de-indentation
_ = """
	Thirteen 2
  Xi 2
	""" // expected-error@-1{{unexpected space in indentation of line in multi-line string literal}}
      // expected-note@-1{{should match tab here}}
      // expected-note@-3{{change indentation of this line to match closing delimiter}} {{1-3=	}}

// multiple spaces are not the same as a tab for de-indentation
_ = """
		Fourteen 2
	  Pi 2
		""" // expected-error@-1{{unexpected space in indentation of line in multi-line string literal}}
        // expected-note@-1{{should match tab here}}
        // expected-note@-3{{change indentation of this line to match closing delimiter}} {{2-4=	}}

// newline currently required after opening """
_ = """Fourteen
    Pi
    """ // expected-error@-2{{multi-line string literal content must begin on a new line}} {{8-8=\n}}

// newline currently required before closing """
_ = """
    Fourteen
    Pi""" // expected-error@-0{{multi-line string literal closing delimiter must begin on a new line}} {{7-7=\n}}

// newline currently required after opening """
_ = """""" // expected-error@-0{{multi-line string literal content must begin on a new line}} {{8-8=\n}}

// newline currently required after opening """
_ = """ """ // expected-error@-0{{multi-line string literal content must begin on a new line}} {{8-8=\n}}

// two lines should get only one error
_ = """
    Hello,
        World!
	"""     // expected-error@-2{{unexpected space in indentation of next 2 lines in multi-line string literal}}
          // expected-note@-1{{should match tab here}}
          // expected-note@-4{{change indentation of these lines to match closing delimiter}} {{1-5=	}} {{1-5=	}}

  _ = """
Zero A
Zero B
	One A
	One B
  Two A
  Two B
Three A
Three B
		Four A
		Four B
			Five A
			Five B
		"""   // expected-error@-12{{insufficient indentation of next 2 lines in multi-line string literal}}
          // expected-note@-1{{should match tab here}}
          // expected-note@-14{{change indentation of these lines to match closing delimiter}} {{1-1=		}} {{1-1=		}}
          // expected-error@-13{{insufficient indentation of next 2 lines in multi-line string literal}}
          // expected-note@-4{{should match tab here}}
          // expected-note@-15{{change indentation of these lines to match closing delimiter}} {{2-2=	}} {{2-2=	}}
          // expected-error@-14{{unexpected space in indentation of next 4 lines in multi-line string literal}}
          // expected-note@-7{{should match tab here}}
          // expected-note@-16{{change indentation of these lines to match closing delimiter}} {{1-1=		}} {{1-1=		}} {{1-1=		}} {{1-1=		}}

_ = "hello\("""
            world
            """
            )!"
            // expected-error@-4 {{cannot find ')' to match opening '(' in string interpolation}}
            // expected-error@-5 {{unterminated string literal}}
            // expected-error@-3 {{unterminated string literal}}

_ = "hello\(
            """
            world
            """)!"
            // expected-error@-4 {{cannot find ')' to match opening '(' in string interpolation}}
            // expected-error@-5 {{unterminated string literal}}
            // expected-error@-3 {{unterminated string literal}}

_ = """
  line one \ non-whitespace
  line two
  """
  // expected-error@-3 {{invalid escape sequence in literal}}

_ = """
  line one
  line two\
  """
  // expected-error@-2 {{escaped newline at the last line is not allowed}} {{11-12=}}

_ = """
  \\\	   
  """
  // expected-error@-2 {{escaped newline at the last line is not allowed}} {{5-10=}}

_ = """
  \(42)\		
  """
  // expected-error@-2 {{escaped newline at the last line is not allowed}} {{8-11=}}

_ = """
  foo\
  """
  // expected-error@-2 {{escaped newline at the last line is not allowed}} {{6-7=}}

_ = """
  foo\
  """
  // expected-error@-1 {{escaped newline at the last line is not allowed}} {{6-7=}}

_ = """
  foo\

  """ // OK because LF + CR is two new lines.

_ = """
\
  """
  // expected-error@-2 {{escaped newline at the last line is not allowed}} {{1-2=}}
  // expected-error@-3{{insufficient indentation of line in multi-line string literal}}
  // expected-note@-3{{should match space here}}
  // expected-note@-5{{change indentation of this line to match closing delimiter}} {{1-1=  }}

_ = """\
  """
  // FIXME: Bad diagnostics
  // expected-error@-3 {{multi-line string literal content must begin on a new line}}
  // expected-error@-4 {{escaped newline at the last line is not allowed}} {{8-9=}}

let _ = """
  foo
  \("bar
  baz
  """
  // expected-error@-3 {{cannot find ')' to match opening '(' in string interpolation}}
  // expected-error@-4 {{unterminated string literal}}