Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct ErrorMessageID for EmptyCatchOrFinallyBlock #14786

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import transform.SymUtils._
def kind = "Reference"

abstract class EmptyCatchOrFinallyBlock(tryBody: untpd.Tree, errNo: ErrorMessageID)(using Context)
extends SyntaxMsg(EmptyCatchOrFinallyBlockID) {
extends SyntaxMsg(errNo) {
def explain = {
val tryString = tryBody match {
case Block(Nil, untpd.EmptyTree) => "{}"
Expand Down
2 changes: 1 addition & 1 deletion compiler/test-resources/repl/i13208.default.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
scala> try 1
1 warning found
-- [E000] Syntax Warning: ------------------------------------------------------
-- [E002] Syntax Warning: ------------------------------------------------------
1 | try 1
| ^^^^^
| A try without catch or finally is equivalent to putting
Expand Down
4 changes: 2 additions & 2 deletions compiler/test-resources/repl/nowarn.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
scala> @annotation.nowarn def f = try 1 // @nowarn doesn't work on first line, ctx.run is null in issueIfNotSuppressed
1 warning found
-- [E000] Syntax Warning: ------------------------------------------------------
-- [E002] Syntax Warning: ------------------------------------------------------
1 | @annotation.nowarn def f = try 1 // @nowarn doesn't work on first line, ctx.run is null in issueIfNotSuppressed
| ^^^^^
| A try without catch or finally is equivalent to putting
Expand All @@ -12,7 +12,7 @@ scala> @annotation.nowarn def f = try 1
def f: Int
scala> def f = try 1
1 warning found
-- [E000] Syntax Warning: ------------------------------------------------------
-- [E002] Syntax Warning: ------------------------------------------------------
1 | def f = try 1
| ^^^^^
| A try without catch or finally is equivalent to putting
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/nowarn/nowarn-parser-error.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| an identifier expected, but 'def' found
|
| longer explanation available when compiling with `-explain`
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn-parser-error.scala:2:10 ----------------------------------
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn-parser-error.scala:2:10 ----------------------------------
2 | def a = try 1 // warn
| ^^^^^
| A try without catch or finally is equivalent to putting
Expand Down
12 changes: 6 additions & 6 deletions tests/neg-custom-args/nowarn/nowarn.check
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:9:10 -----------------------------------------------
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:9:10 -----------------------------------------------
9 |def t1a = try 1 // warning (parser)
| ^^^^^
| A try without catch or finally is equivalent to putting
| its body in a block; no exceptions are handled.
|
| longer explanation available when compiling with `-explain`
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:23:25 ----------------------------------------------
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:23:25 ----------------------------------------------
23 |@nowarn(o.inl) def t2d = try 1 // two warnings (`inl` is not a compile-time constant)
| ^^^^^
| A try without catch or finally is equivalent to putting
| its body in a block; no exceptions are handled.
|
| longer explanation available when compiling with `-explain`
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:31:26 ----------------------------------------------
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:31:26 ----------------------------------------------
31 |@nowarn("id=1") def t4d = try 1 // error and warning (unused nowarn, wrong id)
| ^^^^^
| A try without catch or finally is equivalent to putting
| its body in a block; no exceptions are handled.
|
| longer explanation available when compiling with `-explain`
-- [E000] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:33:28 ----------------------------------------------
-- [E002] Syntax Warning: tests/neg-custom-args/nowarn/nowarn.scala:33:28 ----------------------------------------------
33 |@nowarn("verbose") def t5 = try 1 // warning with details
| ^^^^^
| A try without catch or finally is equivalent to putting
| its body in a block; no exceptions are handled.
Matching filters for @nowarn or -Wconf:
- id=E0
- name=EmptyCatchOrFinallyBlock
- id=E2
- name=EmptyCatchAndFinallyBlock
|
| longer explanation available when compiling with `-explain`
-- [E129] Potential Issue Warning: tests/neg-custom-args/nowarn/nowarn.scala:13:11 -------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions tests/neg-custom-args/nowarn/nowarn.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ object o:
@nowarn("id=E129") def t3a = { 1; 2 }
@nowarn("name=PureExpressionInStatementPosition") def t3b = { 1; 2 }

@nowarn("id=E000") def t4a = try 1
@nowarn("id=E0") def t4b = try 1
@nowarn("id=0") def t4c = try 1
@nowarn("id=E002") def t4a = try 1
@nowarn("id=E2") def t4b = try 1
@nowarn("id=2") def t4c = try 1
@nowarn("id=1") def t4d = try 1 // error and warning (unused nowarn, wrong id)

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