From 4395820b7dd2375b89801fbc04c3712ac6657a7b Mon Sep 17 00:00:00 2001 From: Eliot Date: Mon, 22 Jul 2024 19:24:51 +0200 Subject: [PATCH] Correct fix for #190; Context type hint should be the argument's type instead of the array's type. (Also confirmed not to work in UT2004, so will also need to add diagnostic errors) --- server/src/UC/expressions.ts | 6 ++---- server/src/UC/test/enum/EnumTest.uc | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/UC/expressions.ts b/server/src/UC/expressions.ts index 09ac8e7..cbdfdd2 100644 --- a/server/src/UC/expressions.ts +++ b/server/src/UC/expressions.ts @@ -500,12 +500,10 @@ export class UCElementAccessExpression extends UCExpression { const type = this.expression.getType(); if (type) { this.accessType = resolveElementType(type); - info = { - contextType: this.accessType - }; } - this.argument?.index(document, context, info); + // UC1 and UC2 do not pass a context hint. + this.argument?.index(document, context, { contextType: StaticConstIntType }); } } diff --git a/server/src/UC/test/enum/EnumTest.uc b/server/src/UC/test/enum/EnumTest.uc index 4583c0f..d9e3c6a 100644 --- a/server/src/UC/test/enum/EnumTest.uc +++ b/server/src/UC/test/enum/EnumTest.uc @@ -89,6 +89,7 @@ function EEnumTest ShouldHintEnumTest() { local EEnumTest p1; local byte b1; + local array strings; // in assignments p1 = EEnumTest.EnumCount; @@ -131,8 +132,9 @@ function EEnumTest ShouldHintEnumTest() AcceptByte(EEnumTest.EnumCount); AcceptInt(ET_Other); - // in element accesses + // in element accesses (UC3+) MyEnumArrayPropertyTest[ET_Other] = ET_Other; + strings[ET_Other] = ""; // Hint is also expected for a non-int type array. // in returns return ET_Max;