Skip to content

Commit

Permalink
Fixed runtime error stack trace on Callables (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
lvcabral authored Jan 8, 2025
1 parent 45a22d1 commit 4fba752
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/core/interpreter/BrsFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export function toCallable(func: Expr.Function, name: string = "[Function]") {
}
if (interpreter.environment.gotoLabel !== "") {
interpreter.addError(
new RuntimeError(RuntimeErrorDetail.MissingLineNumber, location)
new RuntimeError(
RuntimeErrorDetail.MissingLineNumber,
location,
interpreter.stack.slice(0, -1)
)
);
}
return BrsInvalid.Instance;
Expand Down
6 changes: 5 additions & 1 deletion src/core/stdlib/CreateObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const CreateObject = new Callable("CreateObject", {
return BrsInvalid.Instance;
} else if (minParams >= 0 && additionalArgs.length !== minParams) {
interpreter.addError(
new RuntimeError(RuntimeErrorDetail.RoWrongNumberOfParams, interpreter.location)
new RuntimeError(
RuntimeErrorDetail.RoWrongNumberOfParams,
interpreter.location,
interpreter.stack.slice(0, -1)
)
);
}
try {
Expand Down
6 changes: 5 additions & 1 deletion src/core/stdlib/GlobalUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ export const ObjFun = new Callable("ObjFun", {
}
}
interpreter.addError(
new RuntimeError(RuntimeErrorDetail.MemberFunctionNotFound, interpreter.location)
new RuntimeError(
RuntimeErrorDetail.MemberFunctionNotFound,
interpreter.location,
interpreter.stack.slice(0, -1)
)
);
},
});
18 changes: 15 additions & 3 deletions src/core/stdlib/Math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export const Cint = new Callable("Cint", {
return toInt32(x, "round");
}
interpreter.addError(
new RuntimeError(RuntimeErrorDetail.TypeMismatch, interpreter.location)
new RuntimeError(
RuntimeErrorDetail.TypeMismatch,
interpreter.location,
interpreter.stack.slice(0, -1)
)
);
},
});
Expand Down Expand Up @@ -76,7 +80,11 @@ export const Fix = new Callable("Fix", {
return toInt32(x, "trunc");
}
interpreter.addError(
new RuntimeError(RuntimeErrorDetail.TypeMismatch, interpreter.location)
new RuntimeError(
RuntimeErrorDetail.TypeMismatch,
interpreter.location,
interpreter.stack.slice(0, -1)
)
);
},
});
Expand All @@ -95,7 +103,11 @@ export const Int = new Callable("Int", {
return toInt32(x);
}
interpreter.addError(
new RuntimeError(RuntimeErrorDetail.TypeMismatch, interpreter.location)
new RuntimeError(
RuntimeErrorDetail.TypeMismatch,
interpreter.location,
interpreter.stack.slice(0, -1)
)
);
},
});
Expand Down

0 comments on commit 4fba752

Please sign in to comment.