diff options
Diffstat (limited to 'src/tools/execution-results.h')
-rw-r--r-- | src/tools/execution-results.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index 0cd40959e..add7cd3a5 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -119,8 +119,18 @@ struct ExecutionResults { if (resultType.isRef() && !resultType.isString()) { // Don't print reference values, as funcref(N) contains an index // for example, which is not guaranteed to remain identical after - // optimizations. - std::cout << resultType << '\n'; + // optimizations. Do not print the type in detail (as even that + // may change due to closed-world optimizations); just print a + // simple type like JS does, 'object' or 'function', but also + // print null for a null (so a null function does not get + // printed as object, as in JS we have typeof null == 'object'). + if (values->size() == 1 && (*values)[0].isNull()) { + std::cout << "null\n"; + } else if (resultType.isFunction()) { + std::cout << "function\n"; + } else { + std::cout << "object\n"; + } } else { // Non-references can be printed in full. So can strings, since we // always know how to print them and there is just one string |