Skip to content

Commit 1c033a7

Browse files
authored
Merge pull request #14786 from ckipp01/correctErrorId
fix: use correct ErrorMessageID for EmptyCatchOrFinallyBlock
2 parents 7b6a073 + daa51df commit 1c033a7

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ import transform.SymUtils._
7878
def kind = MessageKind.Reference
7979

8080
abstract class EmptyCatchOrFinallyBlock(tryBody: untpd.Tree, errNo: ErrorMessageID)(using Context)
81-
extends SyntaxMsg(EmptyCatchOrFinallyBlockID) {
81+
extends SyntaxMsg(errNo) {
8282
def explain = {
8383
val tryString = tryBody match {
8484
case Block(Nil, untpd.EmptyTree) => "{}"

compiler/test-resources/repl/i13208.default.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
scala> try 1
22
1 warning found
3-
-- [E000] Syntax Warning: ------------------------------------------------------
3+
-- [E002] Syntax Warning: ------------------------------------------------------
44
1 | try 1
55
| ^^^^^
66
| A try without catch or finally is equivalent to putting

compiler/test-resources/repl/nowarn.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
scala> @annotation.nowarn def f = try 1 // @nowarn doesn't work on first line, ctx.run is null in issueIfNotSuppressed
22
1 warning found
3-
-- [E000] Syntax Warning: ------------------------------------------------------
3+
-- [E002] Syntax Warning: ------------------------------------------------------
44
1 | @annotation.nowarn def f = try 1 // @nowarn doesn't work on first line, ctx.run is null in issueIfNotSuppressed
55
| ^^^^^
66
| A try without catch or finally is equivalent to putting
@@ -12,7 +12,7 @@ scala> @annotation.nowarn def f = try 1
1212
def f: Int
1313
scala> def f = try 1
1414
1 warning found
15-
-- [E000] Syntax Warning: ------------------------------------------------------
15+
-- [E002] Syntax Warning: ------------------------------------------------------
1616
1 | def f = try 1
1717
| ^^^^^
1818
| A try without catch or finally is equivalent to putting

tests/neg-custom-args/nowarn/nowarn-parser-error.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| an identifier expected, but 'def' found
55
|
66
| longer explanation available when compiling with `-explain`
7-
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn-parser-error.scala:2:10 ----------------------------------
7+
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn-parser-error.scala:2:10 ----------------------------------
88
2 | def a = try 1 // warn
99
| ^^^^^
1010
| A try without catch or finally is equivalent to putting

tests/neg-custom-args/nowarn/nowarn.check

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:9:10 -----------------------------------------------
1+
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:9:10 -----------------------------------------------
22
9 |def t1a = try 1 // warning (parser)
33
| ^^^^^
44
| A try without catch or finally is equivalent to putting
55
| its body in a block; no exceptions are handled.
66
|
77
| longer explanation available when compiling with `-explain`
8-
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:23:25 ----------------------------------------------
8+
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:23:25 ----------------------------------------------
99
23 |@nowarn(o.inl) def t2d = try 1 // two warnings (`inl` is not a compile-time constant)
1010
| ^^^^^
1111
| A try without catch or finally is equivalent to putting
1212
| its body in a block; no exceptions are handled.
1313
|
1414
| longer explanation available when compiling with `-explain`
15-
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:31:26 ----------------------------------------------
15+
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:31:26 ----------------------------------------------
1616
31 |@nowarn("id=1") def t4d = try 1 // error and warning (unused nowarn, wrong id)
1717
| ^^^^^
1818
| A try without catch or finally is equivalent to putting
1919
| its body in a block; no exceptions are handled.
2020
|
2121
| longer explanation available when compiling with `-explain`
22-
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:33:28 ----------------------------------------------
22+
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:33:28 ----------------------------------------------
2323
33 |@nowarn("verbose") def t5 = try 1 // warning with details
2424
| ^^^^^
2525
| A try without catch or finally is equivalent to putting
2626
| its body in a block; no exceptions are handled.
2727
Matching filters for @nowarn or -Wconf:
28-
- id=E0
29-
- name=EmptyCatchOrFinallyBlock
28+
- id=E2
29+
- name=EmptyCatchAndFinallyBlock
3030
|
3131
| longer explanation available when compiling with `-explain`
3232
-- [E129] Potential Issue Warning: tests/neg-custom-args/nowarn/nowarn.scala:13:11 -------------------------------------

tests/neg-custom-args/nowarn/nowarn.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ object o:
2525
@nowarn("id=E129") def t3a = { 1; 2 }
2626
@nowarn("name=PureExpressionInStatementPosition") def t3b = { 1; 2 }
2727

28-
@nowarn("id=E000") def t4a = try 1
29-
@nowarn("id=E0") def t4b = try 1
30-
@nowarn("id=0") def t4c = try 1
28+
@nowarn("id=E002") def t4a = try 1
29+
@nowarn("id=E2") def t4b = try 1
30+
@nowarn("id=2") def t4c = try 1
3131
@nowarn("id=1") def t4d = try 1 // error and warning (unused nowarn, wrong id)
3232

3333
@nowarn("verbose") def t5 = try 1 // warning with details

0 commit comments

Comments
 (0)