From da22e4f04021eee6d43949c5e6a360446d8f8c2a Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Sun, 7 Feb 2021 20:59:56 +0100 Subject: [PATCH] fix: crash in node backend when printing numbers --- builtin/builtin.js | 3 ++- examples/playground.sb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/builtin.js b/builtin/builtin.js index f38db67..bf1145c 100644 --- a/builtin/builtin.js +++ b/builtin/builtin.js @@ -1,7 +1,8 @@ /* START builtins */ function _printf(msg) { - process.stdout.write(msg); + // Message is casted to string to prevent crash + process.stdout.write(msg.toString()); } /* END builtins */ diff --git a/examples/playground.sb b/examples/playground.sb index 502a6ee..6b9a030 100644 --- a/examples/playground.sb +++ b/examples/playground.sb @@ -1,6 +1,6 @@ fn main() { - let arr = ["Foo", "Bar"] + let arr = [1, 2, 3] for x in arr { _printf(x)