Skip to content

Commit 98f02a9

Browse files
committed
Fix type checking for varbit game variables
1 parent 8e57534 commit 98f02a9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- Fix missing indentation for file block.
1818
- Fix type checking for expression lists.
1919
- Fix type checking when there is a type error.
20+
- Fix type checking for varbit game variables.
2021

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

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,21 @@ class RsTypeInferenceVisitor(private val myInferenceData: RsTypeInference) : RsV
328328

329329
override fun visitScopedVariableExpression(o: RsScopedVariableExpression) {
330330
val reference = o.reference?.resolve() as? RsSymSymbol
331-
if (reference == null || reference.fieldList.size < 3) {
331+
if (reference == null) {
332332
o.type = RsErrorType
333333
return
334334
}
335-
o.type = RsPrimitiveType.lookupReferencableOrNull(reference.fieldList[2].text) ?: RsErrorType
335+
val isVarbit = reference.containingFile.virtualFile.nameWithoutExtension == "varbit"
336+
if (isVarbit) {
337+
o.type = RsPrimitiveType.INT
338+
} else {
339+
if (reference.fieldList.size < 3) {
340+
o.error("Missing type field for game variable symbol")
341+
o.type = RsErrorType
342+
return
343+
}
344+
o.type = RsPrimitiveType.lookupReferencableOrNull(reference.fieldList[2].text) ?: RsErrorType
345+
}
336346
}
337347

338348
override fun visitLocalVariableExpression(o: RsLocalVariableExpression) {

0 commit comments

Comments
 (0)