Skip to content

Commit 5109265

Browse files
committed
.
1 parent 9eb87a2 commit 5109265

File tree

4 files changed

+31
-35
lines changed

4 files changed

+31
-35
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff 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
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
-- Error: tests/neg/dedented-string-literals.scala:5:36
1+
-- Error: tests/neg/dedented-string-literals.scala:5:27
22
5 | 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

tests/neg/dedented-string-literals.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff 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 = '''
99
content
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 = '''
2020
some content
21-
// error: missing closing quotes
2221
}

tests/run/dedented-string-literals.check

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ i am cow
33
hear me moo
44

55
With indent:
6-
i am cow
7-
hear me moo
6+
i am cow
7+
hear me moo
88

99
Empty:
1010
[]
@@ -18,14 +18,14 @@ line 1
1818
line 3
1919

2020
Deep indent:
21-
deeply
22-
indented
23-
content
21+
deeply
22+
indented
23+
content
2424

2525
Mixed indent:
26-
first level
27-
second level
28-
third level
26+
first level
27+
second level
28+
third level
2929

3030
With triple quotes:
3131
'''
@@ -45,8 +45,8 @@ Zero indent:
4545
content
4646

4747
Precise:
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)

0 commit comments

Comments
 (0)