Skip to content

Commit d83f9b0

Browse files
Copilotdadhi
andauthored
fix(FlatExpression): use unsigned cast in ChildIdx/ExtraIdx to avoid negative Idx values
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/5b28183a-47f9-4f0d-b706-32e08858c529 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
1 parent 3557b5f commit d83f9b0

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/FastExpressionCompiler/FlatExpression.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ public struct ExpressionNode // 32 bytes: Type(8)+Obj(8)+_typeFlags(2)+NextIdx(
122122
/// <summary>True when this Constant node's value is stored inline in <see cref="Data"/>.</summary>
123123
public bool IsInplaceConst => (_typeFlags & 0x8000) != 0;
124124
/// <summary>First child, or 1-based closure slot for non-inline Constant nodes.</summary>
125-
public Idx ChildIdx => Idx.Of((short)(_data & 0xFFFF));
125+
public Idx ChildIdx => Idx.Of((int)(ushort)(_data & 0xFFFF));
126126
/// <summary>Second child (nil for unary nodes and for New/Call/Invoke args — only used for control nodes).</summary>
127-
public Idx ExtraIdx => Idx.Of((short)((_data >> 32) & 0xFFFF));
127+
public Idx ExtraIdx => Idx.Of((int)(ushort)((_data >> 32) & 0xFFFF));
128128
/// <summary>Raw 8-byte constant bits when <see cref="IsInplaceConst"/> is true.</summary>
129129
public long Data => _data;
130130
}

0 commit comments

Comments
 (0)