Skip to content

Commit 4d40f86

Browse files
committed
describe the common issues
1 parent 94474f0 commit 4d40f86

14 files changed

+166
-90
lines changed

_overviews/scala3-contribution/arch-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: High Level Architecture
33
type: chapter
44
description: This page introduces the high level architecture for the Scala 3 compiler.
5-
num: 11
5+
num: 12
66
previous-page: procedures-checklist
77
next-page: arch-lifecycle
88
---

_overviews/scala3-contribution/arch-lifecycle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Compiler Overview
33
type: section
44
description: This page describes the lifecycle for the Scala 3 compiler.
5-
num: 12
5+
num: 13
66
previous-page: arch-intro
77
next-page: arch-phases
88
---

_overviews/scala3-contribution/arch-phases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Compiler Phases
33
type: section
44
description: This page describes the phases for the Scala 3 compiler.
5-
num: 13
5+
num: 14
66
previous-page: arch-lifecycle
77
next-page: arch-types
88
---

_overviews/scala3-contribution/arch-time.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Time in the Compiler
33
type: section
44
description: This page describes the concepts of time in the Scala 3 compiler.
5-
num: 15
5+
num: 16
66
previous-page: arch-types
77
next-page:
88
---

_overviews/scala3-contribution/arch-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Compiler Types
33
type: section
44
description: This page discusses the representation of types in the compiler
5-
num: 14
5+
num: 15
66
previous-page: arch-phases
77
next-page: arch-time
88
---
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Common Issue Locations
3+
type: section
4+
description: This page describes common areas of issues around the Scala 3 compiler.
5+
num: 7
6+
previous-page: procedures-navigation
7+
next-page: procedures-inspection
8+
---
9+
10+
Many issues are localised to small domains of the compiler and are self-contained,
11+
here is a non-exhaustive list of such domains, and the files associated with them:
12+
13+
### Pretty Printing of Types and Trees
14+
15+
Objects in the compiler that inherit from [Showable] can be pretty printed.
16+
The pretty-printing of objects is used in many places, from debug output,
17+
to user-facing error messages and printing of trees after each phase.
18+
19+
Look in [RefinedPrinter] (or its parent class [PlainPrinter]) for the implementation of pretty printing.
20+
21+
### Content of Error Messages
22+
23+
You can find most error messages defined in [messages] (with IDs defined in [ErrorMessageID]). If the message
24+
is not defined there, try the `-Ydebug-error` compiler flag, which will print a stack trace leading to the
25+
production of the error.
26+
27+
### Compiler Generated Given Instances
28+
29+
If the issue lies in given instances provided by the compiler, such as `scala.reflect.ClassTag`,
30+
`scala.deriving.Mirror`, `scala.reflect.TypeTest`, `scala.CanEqual`, `scala.ValueOf`,
31+
`scala.reflect.Manifest`, etc, look in [Synthesizer], which provides factories for
32+
given instances.
33+
34+
### Compiler Generated Methods
35+
36+
Members can be generated for many classes, such as `equals` and `hashCode`
37+
for case classes and value classes, and `ordinal` and `fromProduct` for Mirrors.
38+
To change the implementation, see [SyntheticMembers].
39+
40+
### Code Completions
41+
For suggestions to auto-complete method selections, see [Completion].
42+
43+
### Enum Desugaring
44+
See [Desugar] and [DesugarEnums].
45+
46+
### Pattern Match Exhaustivity
47+
See [Space].
48+
49+
### Metaprogramming
50+
51+
#### Quotes Reflection
52+
See the [quoted runtime package][quotes-impl].
53+
54+
#### Inline match
55+
See [Inliner].
56+
57+
#### Compiletime Ops Types
58+
See `tryCompiletimeConstantFold` in [Types].
59+
60+
[Showable]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/printing/Showable.scala
61+
[PlainPrinter]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala
62+
[RefinedPrinter]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
63+
[ErrorMessageID]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala
64+
[messages]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/reporting/messages.scala
65+
[Synthesizer]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/typer/Synthesizer.scala
66+
[SyntheticMembers]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/SyntheticMembers.scala
67+
[quotes-impl]: https://github.com/lampepfl/dotty/tree/master/compiler/src/scala/quoted/runtime/impl
68+
[Inliner]: https://github.com/lampepfl/dotty/tree/master/compiler/src/dotty/tools/dotc/typer/Inliner.scala
69+
[Types]: https://github.com/lampepfl/dotty/tree/master/compiler/src/dotty/tools/dotc/core/Types.scala
70+
[Completion]: https://github.com/lampepfl/dotty/tree/master/compiler/src/dotty/tools/dotc/interactive/Completion.scala
71+
[DesugarEnums]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala
72+
[Desugar]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/ast/Desugar.scala
73+
[Space]: https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

_overviews/scala3-contribution/procedures-cheatsheet.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ previous-page: procedures-intro
77
next-page: procedures-reproduce
88
---
99

10+
This page is a quick-reference guide for common tasks while working with the compiler.
11+
For more in-depth explainations, see the rest of this chapter.
12+
1013
## sbt Commands
1114

1215
The following commands can be run within the shell after running `sbt` in the dotty directory.
1316

14-
| Command | Description |
15-
|-----------------------------------|------------------------------------------------------------------|
16-
| `scala3/scalac local/Foo.scala` | Compile the given file – path relative to the dotty directory. |
17-
| `scala3/scala Foo` | Run class `Foo` with dotty directory on the classpath |
18-
| `repl` | Start a REPL with the bootstrapped compiler |
17+
| Command | Description |
18+
|------------------------------------|------------------------------------------------------------------|
19+
| `scala3-bootstrapped/test` | Run all tests for Scala 3 |
20+
| `scala3-bootstrapped/publishLocal` | Build Scala 3 for use in local projects |
21+
| `scala3/scalac local/Foo.scala` | Compile the given file – path relative to the dotty directory. |
22+
| `scala3/scala Foo` | Run class `Foo` with dotty directory on the classpath |
23+
| `repl` | Start a REPL with the bootstrapped compiler |
24+
| `testCompilation tests/pos` | Run test suites on files in the `tests/pos` directory. |
1925
| <code>testOnly<br/>dotty.tools.dotc.CompilationTests<br/>-- *pos</code> | Run test `pos` from `CompilationTests` suite. |
20-
| `testCompilation tests/pos` | Run test suites on files in the `tests/pos` directory. |
21-
| `scala3-bootstrapped/test` | Run all tests for Scala 3 |
2226
| <code>scala3-compiler/Test/runMain<br/>dotty.tools.printTypes</code> | Print types underlying representation |
2327
| <code>scala3/scalac -print-tasty<br/>local/out/Foo.tasty</code> | Print the TASTy of top-level class `Foo` |
2428

_overviews/scala3-contribution/procedures-checklist.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Checklist before opening a Pull Request
2+
title: Pull Request Checklist
33
type: section
44
description: This page describes a checklist before opening a Pull Request to the Scala 3 compiler.
5-
num: 10
5+
num: 11
66
previous-page: procedures-testing
77
next-page: arch-intro
88
---

_overviews/scala3-contribution/procedures-efficiency.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
---
2-
title: Getting Efficient
2+
title: Improving Your Workflow
33
type: section
44
description: This page describes improving efficiency of debugging the Scala 3 compiler.
5-
num: 8
5+
num: 9
66
previous-page: procedures-inspection
77
next-page: procedures-testing
88
---
99

10-
At the Navigation and Inspections sections, we have covered some techniques of working with the compiler. One repeating theme is that there are certain things that need to be done repeatedly and a lot. These are, e.g.:
10+
In the previous sections, we have covered some techniques of working with the compiler.
11+
Some of these techniques can be used repetitively, e.g.:
1112

1213
- Navigating stack frames
1314
- Printing variables in certain ways
1415
- Instrumenting variable definitions with tracers
1516

16-
These seemingly tiny and insignificant things take a lot of time. They also reduce productivity: if the cost (in terms of time and effort) of navigating to a stack frame is high, you'll think twice before doing so, and possibly miss valuable information.
17+
The above procedures often take a lot of time when done manually, reducing productivity:
18+
as the cost (in terms of time and effort) is high, you may avoid attempting to do so,
19+
and possibly miss valuable information.
1720

18-
So, if you're doing those things really frequently, it's a good idea to spend some time scripting your editor to allow you to do them fast. E.g. you can set up your editor to take you to a stack frame when you click it or create text editor macros to instrument variables for printing.
21+
If you're doing those things really frequently, it is recommended to script your editor
22+
to reduce the number of steps. E.g. navigating to the definition of a stack frame
23+
part when you click it, or instrumenting variables for printing.
1924

2025
An example of how it is done for Sublime Text 3 is [here](https://github.com/anatoliykmetyuk/scala-debug-sublime).
2126

_overviews/scala3-contribution/procedures-inspection.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: Inspection
2+
title: How to Inspect Values
33
type: section
44
description: This page describes inspecting semantic values in the Scala 3 compiler.
5-
num: 7
6-
previous-page: procedures-navigation
5+
num: 8
6+
previous-page: procedures-areas
77
next-page: procedures-efficiency
88
---
99

0 commit comments

Comments
 (0)