Skip to content

Commit

Permalink
Correct fix for #190; Context type hint should be the argument's type…
Browse files Browse the repository at this point in the history
… instead of the array's type. (Also confirmed not to work in UT2004, so will also need to add diagnostic errors)
  • Loading branch information
EliotVU committed Jul 22, 2024
1 parent 56ac8b6 commit 4395820
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions server/src/UC/expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}

Expand Down
4 changes: 3 additions & 1 deletion server/src/UC/test/enum/EnumTest.uc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function EEnumTest ShouldHintEnumTest()
{
local EEnumTest p1;
local byte b1;
local array<string> strings;

// in assignments
p1 = EEnumTest.EnumCount;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4395820

Please sign in to comment.