Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
fix: call toString() on println inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
R-unic committed Oct 5, 2023
1 parent ba6d144 commit 07cb76f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/runtime/interpreter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import util from "util";

import { RuntimeError } from "../errors";
import type { ValueType } from "../code-analysis/type-checker";
import { Token } from "../code-analysis/syntax/token";
Expand Down Expand Up @@ -109,7 +111,7 @@ export default class Interpreter implements AST.Visitor.Expression<ValueType>, A
}

public visitPrintlnStatement(stmt: PrintlnStatement): void {
console.log(...stmt.expressions.map(expr => this.evaluate(expr)));
console.log(...stmt.expressions.map(expr => this.evaluate(expr)).map(value => value?.toString()));
}

public visitExpressionStatement(stmt: ExpressionStatement): ValueType {
Expand Down
2 changes: 1 addition & 1 deletion tools/p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class P {
if (this.executionOptions.outputResult) {
const stringified = result instanceof PValue ?
result.toString()
: util.inspect(result, { colors: true, compact: !(result instanceof Array) || result.length < 5 });
: util.inspect(result, { colors: true });

console.log("↳".gray(8), stringified);
}
Expand Down

0 comments on commit 07cb76f

Please sign in to comment.