Skip to content

Commit ab963e1

Browse files
committed
add overassign diagnostics
1 parent beeb166 commit ab963e1

File tree

3 files changed

+2
-19
lines changed

3 files changed

+2
-19
lines changed

compiler/src/main/scala/edg/compiler/ConstProp.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,9 @@ class ConstProp() {
207207
} else {
208208
if (!forcedParams.contains(target)) {
209209
if (params.nodeDefinedAt(target)) { // TODO add propagated assign
210-
// paramSource.get(target).map { case (root, constrName, value) =>
211-
// CompilerError.OverAssignCause.Assign(target, root, constrName, value)
212-
// }.toSeq
210+
val (prevRoot, prevConstr, _) = paramSource.get(target).getOrElse("?", "?", "")
213211
paramErrors.getOrElseUpdate(target, mutable.ListBuffer()).append(
214-
ErrorValue(s"over-assign from $root.$constrName")
212+
ErrorValue(s"over-assign from $root.$constrName, prev assigned from $prevRoot.$prevConstr")
215213
)
216214
return // first set "wins"
217215
}

compiler/src/test/scala/edg/compiler/ConstPropAssignTest.scala

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,6 @@ class ConstPropAssignTest extends AnyFlatSpec {
178178
constProp2.getValue(IndirectDesignPath() + "a") should equal(Some(IntValue(3)))
179179
}
180180

181-
it should "not propagate ErrorValues" in {
182-
import edgir.expr.expr.BinaryExpr.Op
183-
val constProp = new ConstProp()
184-
constProp.addDeclaration(DesignPath() + "a", ValInit.Integer)
185-
constProp.addDeclaration(DesignPath() + "b", ValInit.Integer)
186-
constProp.addAssignValue(IndirectDesignPath() + "a", ErrorValue("error!"))
187-
constProp.addAssignExpr(
188-
IndirectDesignPath() + "b",
189-
ValueExpr.BinOp(Op.ADD, ValueExpr.Literal(3), ValueExpr.Ref("a")),
190-
)
191-
constProp.getValue(IndirectDesignPath() + "a") should equal(None)
192-
constProp.getValue(IndirectDesignPath() + "b") should equal(None)
193-
constProp.getErrors should not be empty
194-
}
195-
196181
it should "not propagate generated ErrorValues" in {
197182
import edgir.expr.expr.BinaryExpr.Op
198183
val constProp = new ConstProp()
-5.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)