File tree Expand file tree Collapse file tree 4 files changed +31
-35
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 4 files changed +31
-35
lines changed Original file line number Diff line number Diff line change @@ -1322,13 +1322,10 @@ object Scanners {
13221322 nextRawChar()
13231323 }
13241324
1325- if (endQuoteCount == quoteCount && ( ch == SU || ch == CR || ch == LF || ch == ' ' || ch == ' \t ' || ch == ';' ) ) {
1326- // Found closing delimiter
1325+ if (endQuoteCount == quoteCount && ch != ' \' ' ) {
1326+ // Found closing delimiter (not followed by another quote)
13271327 foundClosing = true
13281328 closingIndent = currentIndent.toString
1329- // Consume any trailing whitespace/newlines after closing quotes
1330- while (ch == ' ' || ch == '\t ' ) nextChar()
1331- if (ch == CR || ch == LF ) nextChar()
13321329 } else {
13331330 // False alarm, these quotes are part of the content
13341331 // We need to restore and add them to current line
Original file line number Diff line number Diff line change 1- -- Error: tests/neg/dedented-string-literals.scala:5:36
1+ -- Error: tests/neg/dedented-string-literals.scala:5:27
225 | val noNewlineAfterOpen = '''content on same line // error
3- | ^
3+ | ^
44 |dedented string literal must start with newline after opening quotes
5- -- Error: tests/neg/dedented-string-literals.scala:8:0
6- 8 |content
7- |^
5+ -- Error: tests/neg/dedented-string-literals.scala:8:20
6+ 8 | val notIndented = '''
7+ | ^
88 |line in dedented string literal must be indented at least as much as the closing delimiter
9- -- Error: tests/neg/dedented-string-literals.scala:14:0
10- 14 | space line
11- | ^
9+ -- Error: tests/neg/dedented-string-literals.scala:13:24
10+ 13 | val mixedTabsSpaces = '''
11+ | ^
1212 |dedented string literal cannot mix tabs and spaces in indentation
13- -- [E040] Syntax Error: tests/neg/dedented-string-literals.scala:19:0
14- 19 | // error: missing closing quotes
15- | ^ ^
13+ -- [E040] Syntax Error: tests/neg/dedented-string-literals.scala:19:17
14+ 19 | val unclosed = '''
15+ | ^
1616 |unclosed dedented string literal
Original file line number Diff line number Diff line change @@ -4,19 +4,18 @@ object DedentedStringErrors {
44 // Error: No newline after opening quotes
55 val noNewlineAfterOpen = ''' content on same line // error
66
7- // Error: Content not indented enough
7+ // Error: Content not indented enough // error
88 val notIndented = '''
99content
10- ''' // error
10+ '''
1111
12- // Error: Mixed tabs and spaces
12+ // Error: Mixed tabs and spaces // error
1313 val mixedTabsSpaces = '''
1414 tab line
1515 space line
16- ''' // error
16+ '''
1717
18- // Error: Unclosed literal
18+ // Error: Unclosed literal // error
1919 val unclosed = '''
2020some content
21- // error: missing closing quotes
2221}
Original file line number Diff line number Diff line change 33hear me moo
44
55With indent:
6- i am cow
7- hear me moo
6+ i am cow
7+ hear me moo
88
99Empty:
1010[]
@@ -18,14 +18,14 @@ line 1
1818line 3
1919
2020Deep indent:
21- deeply
22- indented
23- content
21+ deeply
22+ indented
23+ content
2424
2525Mixed indent:
26- first level
27- second level
28- third level
26+ first level
27+ second level
28+ third level
2929
3030With triple quotes:
3131'''
@@ -45,8 +45,8 @@ Zero indent:
4545content
4646
4747Precise:
48- Length: 7
49- Content: [ab
50- cd]
51- Chars: List(a, b,
52- , c, d)
48+ Length: 9
49+ Content: [ ab
50+ cd]
51+ Chars: List( , , a, b,
52+ , , , c, d)
You can’t perform that action at this time.
0 commit comments