mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
^
From End index is relative to length instead of length-1
This commit is contained in:
parent
fa3198f82a
commit
299bea0eaa
6 changed files with 30 additions and 27 deletions
|
@ -20859,7 +20859,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp
|
|||
}
|
||||
else
|
||||
{
|
||||
// Add as a `^0`
|
||||
// Add as a `^1`
|
||||
auto indexType = mModule->ResolveTypeDef(mModule->mCompiler->mIndexTypeDef)->ToTypeInstance();
|
||||
rightTypedValueExpr.mRefNode = opToken;
|
||||
|
||||
|
@ -20867,7 +20867,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfExpression* leftExpression, BfExp
|
|||
|
||||
SizedArray<BfIRValue, 8> tupleMembers;
|
||||
tupleMembers.Add(valueTypeEmpty);
|
||||
tupleMembers.Add(mModule->mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, 0));
|
||||
tupleMembers.Add(mModule->mBfIRBuilder->CreateConst(BfTypeCode_IntPtr, 1));
|
||||
auto tupleValue = mModule->mBfIRBuilder->CreateConstAgg(mModule->mBfIRBuilder->MapType(indexType->mFieldInstances[0].mResolvedType), tupleMembers);
|
||||
|
||||
SizedArray<BfIRValue, 8> indexMembers;
|
||||
|
|
|
@ -145,23 +145,26 @@ namespace Tests
|
|||
Test.Assert(total == 20+30+40+50+60+70+80+90+100);
|
||||
|
||||
total = 0;
|
||||
for (int i in iList[...^1])
|
||||
for (int i in iList[...^2])
|
||||
total += i;
|
||||
Test.Assert(total == 10+20+30+40+50+60+70+80+90);
|
||||
|
||||
total = 0;
|
||||
for (int i in iList[..<^1])
|
||||
for (int i in iList[..<^2])
|
||||
total += i;
|
||||
Test.Assert(total == 10+20+30+40+50+60+70+80);
|
||||
|
||||
total = 0;
|
||||
for (int i in iList[...^1][1...^1])
|
||||
for (int i in iList[...^2][1...^2])
|
||||
total += i;
|
||||
Test.Assert(total == 20+30+40+50+60+70+80);
|
||||
|
||||
var str = scope String();
|
||||
(2...^3).ToString(str);
|
||||
Test.Assert(str == "2...^3");
|
||||
|
||||
int[] iEmptyArr = scope .();
|
||||
var emptySpan = iEmptyArr[...];
|
||||
}
|
||||
|
||||
public static void TestEnumerator1(EnumeratorTest e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue