From a894f06392af782ffc7ce9392a085d21e0864a66 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Thu, 4 Mar 2021 16:55:03 +0000 Subject: [PATCH] Fix repl output after .pseudoToNative changes In PR #450 Interpreter.prototype.pseudoToNative was modified to make the JSON.stringify builtin behave more correctly (per ES5.1 spec). Unfortunately this meant that in repl any expression that yeilded a function would be shown as having value undefined. Fix repl so that if the expression evaluates to a function that function is printed. (It will still hide methods, as JSON.stringify does. But this is better than before, and perfecting repl is not a priority at the moment.) --- server/repl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/repl b/server/repl index e7ec63b8..c0efe658 100755 --- a/server/repl +++ b/server/repl @@ -55,7 +55,12 @@ rl.on('line', function(line) { return; } intrp.run(); - console.log(intrp.pseudoToNative(thread.value)); + const value = thread.value; + if (value instanceof intrp.Function) { + console.log(value.toString()); + } else { + console.log('%o', intrp.pseudoToNative(thread.value)); + } } finally { rl.prompt(); }