Skip to content

Commit 54a1ced

Browse files
committed
Inlined the code examples in the unbound placeholder explanation.
1 parent a5a4ec7 commit 54a1ced

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

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

+4-24
Original file line numberDiff line numberDiff line change
@@ -407,26 +407,6 @@ object messages {
407407

408408
val msg = hl"unbound placeholder parameter; incorrect use of `_`"
409409

410-
val codeUnboundInBlock =
411-
"""
412-
|{ _ }
413-
""".stripMargin
414-
415-
val codeBoundInBlock =
416-
"""
417-
|x => { x }
418-
""".stripMargin
419-
420-
val codeUnboundVal =
421-
"""
422-
|val a = _
423-
""".stripMargin
424-
425-
val codeVar =
426-
"""
427-
|var a = _
428-
""".stripMargin
429-
430410
val explanation =
431411
hl"""The `_` placeholder syntax was used where it could not be bound.
432412
|Consider explicitly writing the variable binding.
@@ -436,21 +416,21 @@ object messages {
436416
|
437417
|Example before:
438418
|
439-
|$codeUnboundInBlock
419+
|${"{ _ }"}
440420
|
441421
|Example after:
442422
|
443-
|$codeBoundInBlock
423+
|${"x => { x }"}
444424
|
445425
|Another common occurrence for this error is defining a val with `_`:
446426
|
447-
|$codeUnboundVal
427+
|${"val a = _"}
448428
|
449429
|But this val definition isn't very useful, it can never be assigned
450430
|another value. And thus will always remain uninitialized.
451431
|Consider replacing the ${"val"} with ${"var"}:
452432
|
453-
|$codeVar
433+
|${"var a = _"}
454434
|
455435
|Note that this use of `_` is not placeholder syntax,
456436
|but an uninitialized var definition

0 commit comments

Comments
 (0)