aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-12-07 07:55:32 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-12-07 07:55:32 -0500
commitbfb89d64badd6bc3b106a277ceb952d9b60baf8b (patch)
tree2c513f92f459d8dbaaed1c2c155de28e28082257
parentc868a5746d74d098a5d4a1e37b3b02b944a4f045 (diff)
Fix JS VM's handling of single-body block function with a header
-rw-r--r--docs/bqn.js2
-rw-r--r--test/cases/header.bqn1
2 files changed, 2 insertions, 1 deletions
diff --git a/docs/bqn.js b/docs/bqn.js
index 1314e40c..bfa87f34 100644
--- a/docs/bqn.js
+++ b/docs/bqn.js
@@ -134,10 +134,10 @@ let run = (B,O,F,S,L,T,src,env) => { // Bytecode, Objects, Blocks, Bodies, Locat
let c,vid,def;
if (isnum(ind)) {
[c,vid] = gen(ind);
+ c="do {"+c+"} while (0);\nthrow Error('No matching case');\n";
if (useenv) { c = "const e=env;"+c; env.vid=vid; }
else if (imm) c = "const e=[...e2];e.vid=vid;e.p=oe;"+c;
else c = "const fn=(x, w)=>{const e=[...e2];e.vid=vid;e.p=oe;e[0]=fn;e[1]=x;e[2]=w;"+c+"};"+repdf[type]+"return fn;";
- c="do {"+c+"} while (0);\nthrow Error('No matching case');\n";
def = useenv ? "env" : ("new Array("+vid.length+").fill(null)");
} else {
if (imm !== +(ind.length<2)) throw "Internal error: malformed block info";
diff --git a/test/cases/header.bqn b/test/cases/header.bqn
index 7c9d5a04..d43643ff 100644
--- a/test/cases/header.bqn
+++ b/test/cases/header.bqn
@@ -145,6 +145,7 @@
2 % {𝕊a‿b:b-a}3‿5
! % {𝕊a‿b:𝕩}↕4
2 % {A‿_b_:b-a}3‿5
+2 % 4{𝕨𝕊a‿b:𝕨-b÷a}3‿6
! % {a‿b:𝕩}↕4
3 % {𝕊a‿B:b-a;≠𝕩}3‿5‿6
1 % >´{⟨x⟩:1;𝕩:0}¨⟨2⟩‿6