git » jacl.git » commit b4bd8f4

Ensure GOs in TAGBODY preludes aren't turned into go-continue

author Alan Dipert
2020-04-16 05:04:03 UTC
committer Alan Dipert
2020-04-16 05:04:03 UTC
parent 3456f2bda4301223e3541241ec9f812fb59eaeeb

Ensure GOs in TAGBODY preludes aren't turned into go-continue

jacl.js +7 -1

diff --git a/jacl.js b/jacl.js
index 6ad45d6..75750f7 100644
--- a/jacl.js
+++ b/jacl.js
@@ -1578,6 +1578,10 @@ const findNodes = (root, pred) => {
   return found;
 };
 
+const tagbodyPreludeGos = tagbody => {
+  return findNodes({ children: tagbody.prelude }, x => x.op === 'go');
+};
+
 const optimizeGo = node => {
   const gos = findNodes(node, x => {
     return x.op === 'go' && x.context !== 'expr';
@@ -1585,7 +1589,9 @@ const optimizeGo = node => {
   next: for (const go of gos) {
     let parent = go.parent;
     while (parent) {
-      if (parent.op === 'tagbody' && go.tagbodyId === parent.id) {
+      if (parent.op === 'tagbody'
+          && go.tagbodyId === parent.id
+          && !tagbodyPreludeGos(parent).includes(go)) {
         go.op = 'go-continue';
         continue next;
       }