on master help sign in
Merge pull request #4617 from unalos/master

Fixing error message on partial pattern matching failure.

commitecf297a9947fe7a7cb2d9e58ea0ebcf8d4348a4a authorNiklas Larsson <metaniklas@gmail.com> dateThu 20 Dec 2018, 21:13 (8 years ago) parent7855f86097b686
4 files changed+18−5
jsrts/Runtime-javascript.js+6−2 jsrts/Runtime-node.js+10−1 src/IRTS/Compiler.hs+1−1 src/IRTS/JavaScript/AST.hs+1−1
jsrts/Runtime-javascript.js+6−2
@@ -7,5 +7,9 @@ $JSRTS.prim_systemInfo = function (index) {
77 }
88 return "";
99};
10−$JSRTS.prim_writeStr = function (x) { return console.log(x) }
11−$JSRTS.prim_readStr = function () { return prompt('Prelude.getLine') };
10+
11+$JSRTS.prim_writeStr = function (x) { return console.log(x) };
12+
13+$JSRTS.prim_readStr = function () { return prompt('Prelude.getLine') };
14+
15+$JSRTS.die = function (message) { throw new Error(message) };
jsrts/Runtime-node.js+10−1
@@ -1,5 +1,7 @@
11$JSRTS.os = require('os');
2+
23$JSRTS.fs = require('fs');
4+
35$JSRTS.prim_systemInfo = function (index) {
46 switch (index) {
57 case 0:
@@ -9,7 +11,9 @@ $JSRTS.prim_systemInfo = function (index) {
911 }
1012 return "";
1113};
12−$JSRTS.prim_writeStr = function (x) { return process.stdout.write(x) }
14+
15+$JSRTS.prim_writeStr = function (x) { return process.stdout.write(x) };
16+
1317$JSRTS.prim_readStr = function () {
1418 var ret = '';
1519 var b = new Buffer(1024);
@@ -28,4 +32,9 @@ $JSRTS.prim_readStr = function () {
2832 }
2933 }
3034 return ret;
35+};
36+
37+$JSRTS.die = function (message) {
38+ console.error(message);
39+ process.exit(-1);
3140};
src/IRTS/Compiler.hs+1−1
@@ -533,7 +533,7 @@ irTree top args tree = do
533533
534534irSC :: Name -> Vars -> SC -> Idris LExp
535535irSC top vs (STerm t) = irTerm top vs [] t
536−irSC top vs (UnmatchedCase str) = return $ LLazyExp $ LError str
536+irSC top vs (UnmatchedCase str) = return $ LError str
537537
538538irSC top vs (ProjCase tm alts) = do
539539 tm' <- irTerm top vs [] tm
src/IRTS/JavaScript/AST.hs+1−1
@@ -202,7 +202,7 @@ jsStmt2Text (JsSwitchCase exp l d) =
202202 default2Text Nothing = ""
203203 default2Text (Just z) =
204204 T.concat ["default:\n", indent $ T.concat [jsStmt2Text z, ";\nbreak;\n"]]
205−jsStmt2Text (JsError t) = T.concat ["throw new Error( ", jsAst2Text t, ");"]
205+jsStmt2Text (JsError t) = T.concat ["$JSRTS.die(", jsAst2Text t, ");\n"]
206206jsStmt2Text (JsForever x) =
207207 T.concat ["for(;;) {\n", indent $ jsStmt2Text x, "}\n"]
208208jsStmt2Text JsContinue = "continue;"