From 73c12557c48f3f4c6988d3974b93451eb1ff96d5 Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 11 Sep 2021 13:49:39 +0200 Subject: [PATCH 1/5] Handle compiler crash where there is no stack trace --- cli/asc.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cli/asc.js b/cli/asc.js index f1dfc427f3..b1b69812c7 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -1478,12 +1478,19 @@ function crash(stage, e) { EOL, BAR, "Whoops, the AssemblyScript compiler has crashed during ", stage, " :-(", EOL, BAR, EOL, - BAR, "Here is a stack trace that may or may not be useful:", EOL, - BAR, EOL, - e.stack.replace(/^/mg, BAR), EOL, - BAR, EOL, - BAR, "If it refers to the dist files, try to 'npm install source-map-support' and", EOL, - BAR, "run again, which should then show the actual code location in the sources.", EOL, + (e.stack != null + ? [ + BAR, "Here is a stack trace that may or may not be useful:", EOL, + BAR, EOL, + e.stack.replace(/^/mg, BAR), EOL, + BAR, EOL, + BAR, "If it refers to the dist files, try to 'npm install source-map-support' and", EOL, + BAR, "run again, which should then show the actual code location in the sources.", EOL, + ] + : [ + BAR, "Sadly, there is no stack trace. Perhaps a Binaryen exception above?", EOL + ] + ).join(""), BAR, EOL, BAR, "If you see where the error is, feel free to send us a pull request. If not,", EOL, BAR, "please let us know: https://github.com/AssemblyScript/assemblyscript/issues", EOL, From a382260f32a46ee017e08e642d20e7951400366b Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 11 Sep 2021 13:52:06 +0200 Subject: [PATCH 2/5] hint at console for Wasm studio --- cli/asc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/asc.js b/cli/asc.js index b1b69812c7..64d69c0a8b 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -1488,7 +1488,7 @@ function crash(stage, e) { BAR, "run again, which should then show the actual code location in the sources.", EOL, ] : [ - BAR, "Sadly, there is no stack trace. Perhaps a Binaryen exception above?", EOL + BAR, "There is no stack trace. Perhaps a Binaryen exception above / in console?", EOL ] ).join(""), BAR, EOL, From d267eda942e019f58ee1332381cd351b36147cb5 Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 11 Sep 2021 14:03:52 +0200 Subject: [PATCH 3/5] check for string --- cli/asc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/asc.js b/cli/asc.js index 64d69c0a8b..3f6666ca13 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -1478,7 +1478,7 @@ function crash(stage, e) { EOL, BAR, "Whoops, the AssemblyScript compiler has crashed during ", stage, " :-(", EOL, BAR, EOL, - (e.stack != null + (typeof e.stack === "string" ? [ BAR, "Here is a stack trace that may or may not be useful:", EOL, BAR, EOL, From 81cf31cdc5af2c7979ace1f79dff64140f1d4daf Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 11 Sep 2021 14:07:17 +0200 Subject: [PATCH 4/5] print whatever the stack is --- cli/asc.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/asc.js b/cli/asc.js index 3f6666ca13..470b061ddb 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -1488,7 +1488,9 @@ function crash(stage, e) { BAR, "run again, which should then show the actual code location in the sources.", EOL, ] : [ - BAR, "There is no stack trace. Perhaps a Binaryen exception above / in console?", EOL + BAR, "There is no stack trace. Perhaps a Binaryen exception above / in console?", EOL, + BAR, EOL, + BAR, "> " + e.stack, EOL ] ).join(""), BAR, EOL, From c464e71f002664798e2e4c4ec9d44d1c61b8eafb Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 11 Sep 2021 14:23:59 +0200 Subject: [PATCH 5/5] wording --- cli/asc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/asc.js b/cli/asc.js index 470b061ddb..6bccf12a4d 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -1480,7 +1480,7 @@ function crash(stage, e) { BAR, EOL, (typeof e.stack === "string" ? [ - BAR, "Here is a stack trace that may or may not be useful:", EOL, + BAR, "Here is the stack trace hinting at the problem, perhaps it's useful?", EOL, BAR, EOL, e.stack.replace(/^/mg, BAR), EOL, BAR, EOL,