diff --git a/src/runtime/interpreter.ts b/src/runtime/interpreter.ts index 85a00e79..f003c843 100644 --- a/src/runtime/interpreter.ts +++ b/src/runtime/interpreter.ts @@ -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"; @@ -109,7 +111,7 @@ export default class Interpreter implements AST.Visitor.Expression, 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 { diff --git a/tools/p.ts b/tools/p.ts index 7360a2ca..3db16be5 100644 --- a/tools/p.ts +++ b/tools/p.ts @@ -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); }