Skip to content

Commit

Permalink
Thanks @iivillian
Browse files Browse the repository at this point in the history
  • Loading branch information
atrexus committed Apr 2, 2024
1 parent f013e55 commit 28a8619
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Unluau/Chunk/Luau/Function.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public Function(BinaryReader reader, Version version, string[] symbolTable)
ClosureTable = ReadClosureTable(reader);

LineDefined = reader.ReadSize();
DebugSymbolIndex = reader.ReadIndex();
DebugSymbolIndex = reader.ReadIndex() - 1;

if (reader.ReadBoolean())
LineInformation = new LineInformation(reader, Instructions.Length);
Expand Down Expand Up @@ -254,7 +254,7 @@ public override string ToString()
builder.AppendLine($"{ParameterCount}{(IsVariadic ? "+" : string.Empty)} param(s), {SlotCount} slot(s), {UpvalueCount} upvalue(s), {Constants.Length} constant(s), {ClosureTable.Length} function(s)");

// Write function name
builder.Append($"function {(DebugSymbolIndex is null ? "main" : _symbolTable[(int)DebugSymbolIndex - 1])}(");
builder.Append($"function {(DebugSymbolIndex is null ? "main" : _symbolTable[(int)DebugSymbolIndex])}(");

// Write function parameters
for (int i = 0; i < ParameterCount; ++i)
Expand Down Expand Up @@ -671,7 +671,7 @@ private ClosureContext GetClosureContext()
for (int slot = 0; slot < ParameterCount; ++slot)
parameters.Add(new Variable(new(pcScope, lines), slot));

string? name = DebugSymbolIndex is null ? null : _symbolTable[(int)DebugSymbolIndex - 1];
string? name = DebugSymbolIndex is null ? null : _symbolTable[(int)DebugSymbolIndex];

return new()
{
Expand Down

0 comments on commit 28a8619

Please sign in to comment.