Skip to content

Commit c6d5d2b

Browse files
committed
Start debugging value not found error
1 parent f6d6b17 commit c6d5d2b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ class Objects(using Context @constructorOnly):
398398
case Some(theValue) =>
399399
theValue
400400
case _ =>
401+
throw new RuntimeException("valValue")
401402
report.warning("[Internal error] Value not found " + x.show + "\nenv = " + data.show + ". " + Trace.show, Trace.position)
402403
Bottom
403404

@@ -771,9 +772,9 @@ class Objects(using Context @constructorOnly):
771772
end if
772773

773774
case _ =>
774-
// by-name closure
775-
given Env.Data = env
776-
extendTrace(code) { eval(code, thisV, klass, cacheResult = true) }
775+
// Should be unreachable, by-name closures are handled by readLocal
776+
report.warning("[Internal error] Only DefDef should be possible here, but found " + code.show + ". " + Trace.show, Trace.position)
777+
Bottom
777778

778779
case ValueSet(vs) =>
779780
vs.map(v => call(v, meth, args, receiver, superType)).join
@@ -976,12 +977,13 @@ class Objects(using Context @constructorOnly):
976977
* @param sym The symbol of the variable.
977978
* @param value The value of the initializer.
978979
*/
979-
def initLocal(sym: Symbol, value: Value): Contextual[Unit] = log("initialize local " + sym.show + " with " + value.show, printer) {
980+
def initLocal(sym: Symbol, value: Value)(using data: Env.Data, ctx: Context): Contextual[Unit] = log("initialize local " + sym.show + " with " + value.show, printer) {
980981
if sym.is(Flags.Mutable) then
981982
val addr = Heap.localVarAddr(summon[Regions.Data], sym, State.currentObject)
982983
Env.setLocalVar(sym, addr)
983984
Heap.writeJoin(addr, value)
984985
else
986+
System.out.println("initLocal sym: " + sym.show + " val: " + value.show + " data: " + data.show)
985987
Env.setLocalVal(sym, value)
986988
}
987989

@@ -1015,12 +1017,15 @@ class Objects(using Context @constructorOnly):
10151017
val rhs = sym.defTree.asInstanceOf[ValDef].rhs
10161018
eval(rhs, thisV, sym.enclosingClass.asClass, cacheResult = true)
10171019
else
1020+
System.out.println("env: " + env.show)
1021+
System.out.println("sym: " + sym.show)
10181022
// Assume forward reference check is doing a good job
10191023
val value = Env.valValue(sym)
10201024
if isByNameParam(sym) then
10211025
value match
10221026
case fun: Fun =>
10231027
given Env.Data = Env.ofByName(sym, fun.env)
1028+
System.out.println("created new env " + fun.code.show)
10241029
eval(fun.code, fun.thisV, fun.klass)
10251030
case Cold =>
10261031
report.warning("Calling cold by-name alias. " + Trace.show, Trace.position)

0 commit comments

Comments
 (0)