Skip to content

Commit 87b841b

Browse files
committed
Review fixes
1 parent b2734b5 commit 87b841b

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

usvm-ts/src/main/kotlin/org/usvm/machine/expr/TsExprResolver.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ class TsExprResolver(
788788
val fakeType = instanceRef.getFakeType(scope)
789789

790790
// If we want to get length from a fake object, we assume that it is an array.
791-
scope.assert(fakeType.refTypeExpr)
791+
scope.doWithState { pathConstraints += fakeType.refTypeExpr }
792792

793793
val refLValue = getIntermediateRefLValue(instanceRef.address)
794794
val obj = scope.calcOnState { memory.read(refLValue) }
@@ -872,6 +872,12 @@ class TsExprResolver(
872872
}
873873

874874
override fun visit(expr: EtsNewArrayExpr): UExpr<out USort>? = with(ctx) {
875+
val arrayType = expr.type
876+
877+
require(arrayType is EtsArrayType) {
878+
"Expected EtsArrayType in newArrayExpr, but got ${arrayType::class.simpleName}"
879+
}
880+
875881
scope.calcOnState {
876882
val size = resolve(expr.size) ?: return@calcOnState null
877883

@@ -902,8 +908,6 @@ class TsExprResolver(
902908
blockOnFalseState = allocateException(EtsStringType) // TODO incorrect exception type
903909
)
904910

905-
val arrayType = expr.type as EtsArrayType
906-
907911
if (arrayType.elementType is EtsArrayType) {
908912
TODO("Multidimensional arrays are not supported yet, https://github.com/UnitTestBot/usvm/issues/287")
909913
}

usvm-ts/src/test/kotlin/org/usvm/util/TsTestResolver.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ class TsTestResolver {
109109
resolvedLValuesToFakeObjects += arrayIndexLValue to fakeObject
110110
}
111111

112-
else -> error("Unexpected lValue type: ${lValue::class.java.name}")
112+
else -> {
113+
error("Unexpected lValue type: ${lValue::class.java.name}")
114+
}
113115
}
114116
}
115117
}
@@ -265,7 +267,9 @@ open class TsTestStateResolver(
265267
resolveExpr(fakeObject.extractRef(finalStateMemory))
266268
}
267269

268-
else -> error("Unsupported fake object type: $fakeType")
270+
else -> {
271+
error("Unsupported fake object type: $fakeType")
272+
}
269273
}
270274
}
271275

usvm-util/src/main/kotlin/org/usvm/test/util/checkers/Matchers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ val ignoreNumberOfAnalysisResults = AnalysisResultsNumberMatcher(
2222

2323
val noResultsExpected = AnalysisResultsNumberMatcher(
2424
description = "No executions expected",
25-
matcherFailedMessage = { it -> "Expected no analysis results, but $it executions were found" }
25+
matcherFailedMessage = { "Expected no analysis results, but $it executions were found" }
2626
) { it == 0 }
2727

2828
class AnalysisResultsNumberMatcher(

0 commit comments

Comments
 (0)