File tree Expand file tree Collapse file tree 3 files changed +35
-7
lines changed
compiler/src/dotty/tools/dotc/ast Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -24,13 +24,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Pro
2424 def uniqueId : Int = myUniqueId
2525
2626 def uniqueId_= (id : Int ): Unit = {
27- if (Positioned .debugId == id) {
28- def printTrace () = {
29- val stack = Thread .currentThread().getStackTrace().map(" > " + _)
30- System .err.println(stack.mkString(s " > Debug tree (id= ${Positioned .debugId}) creation \n > $this\n " , " \n " , " \n " ))
31- }
32- printTrace()
33- }
27+ if (Positioned .debugId == id) ???
3428 myUniqueId = id
3529 }
3630
Original file line number Diff line number Diff line change 1+ ---
2+ layout : doc-page
3+ title : " Debug Macros"
4+ ---
5+
6+ Complex macros may break invariants of the compiler, which leads to compiler crashes.
7+ Here we lists common compiler crashes and how to deal with them.
8+
9+ ## position not set
10+
11+ For this problem, here is the log that is usually shown:
12+
13+ ```
14+ [error] assertion failed: position not set for org.scalactic.anyvals.PosZInt.+$extension3(SizeParam.this.minSize)(
15+ [error] org.scalactic.anyvals.PosZInt.widenToInt(SizeParam.this.sizeRange)
16+ [error] ) # 2326942 of class dotty.tools.dotc.ast.Trees$Apply in library/src-bootstrapped/scala/tasty/reflect/utils/TreeUtils.scala
17+ ```
18+
19+ To debug why the position is not set, note the tree id ` 2326942 ` , and enable
20+ the following compiler option:
21+
22+ ```
23+ -Ydebug-tree-with-id 2326942
24+ ```
25+
26+ With the option above, the compiler will crash when the tree is created. From
27+ the stack trace, we will be able to figure out where the tree is created.
28+
29+ If the position is in the compiler, then either report a compiler bug or
30+ fix the problem with ` .withSpan(tree.span) ` . The following fix is an example:
31+
32+ - https://github.com/lampepfl/dotty/pull/6581
Original file line number Diff line number Diff line change @@ -183,6 +183,8 @@ sidebar:
183183 url : docs/internals/type-system.html
184184 - title : " Dotty Internals 1: Trees & Symbols (Meeting Notes)"
185185 url : docs/internals/dotty-internals-1-notes.html
186+ - title : Debug Macros
187+ url : docs/internals/debug-macros.html
186188 - title : Resources
187189 subsection :
188190 - title : Talks
You can’t perform that action at this time.
0 commit comments