Skip to content

Commit 8e57534

Browse files
committed
Fix type checking when there is a type error
1 parent 95deed0 commit 8e57534

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Fix a bug with script block indentation.
1717
- Fix missing indentation for file block.
1818
- Fix type checking for expression lists.
19+
- Fix type checking when there is a type error.
1920

2021
## [1.2.0] - 2023-08-18
2122

src/main/kotlin/io/runescript/plugin/lang/psi/type/RsTypeExt.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ fun Iterable<RsType>.flatten(): Array<RsType> {
3535
for (type in this) {
3636
when (type) {
3737
is RsTupleType -> flattened.addAll(type.types)
38-
is RsPrimitiveType -> flattened.add(type)
39-
is RsArrayType -> flattened.add(type)
40-
is RsTypeType -> flattened.add(type)
41-
else -> error("Called flatten() on non primitive type array: ${type::class}")
38+
else -> flattened.add(type)
4239
}
4340
}
4441
return flattened.toTypedArray()

src/main/kotlin/io/runescript/plugin/lang/psi/type/inference/RsTypeInferenceVisitor.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
9999
}
100100

101101
private fun RsType?.unfold(): RsType? {
102-
if (this is RsTupleType && types.size == 1) return types[0]
102+
if (this is RsTupleType && types.size == 1) {
103+
return types[0]
104+
}
103105
return this
104106
}
105107

@@ -119,6 +121,12 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
119121
if (unfoldedActualType is RsErrorType || unfoldedExpectedType is RsErrorType) {
120122
return
121123
}
124+
if (unfoldedActualType is RsTupleType && RsErrorType in unfoldedActualType.types) {
125+
return
126+
}
127+
if (unfoldedExpectedType is RsTupleType && RsErrorType in unfoldedExpectedType.types) {
128+
return
129+
}
122130
if (unfoldedExpectedType == RsPrimitiveType.OBJ && unfoldedActualType == RsPrimitiveType.NAMEDOBJ) {
123131
// namedobj extends obj
124132
return

0 commit comments

Comments
 (0)