Skip to content

Commit

Permalink
Merge pull request #4617 from unalos/master
Browse files Browse the repository at this point in the history
Fixing error message on partial pattern matching failure.
  • Loading branch information
melted committed Dec 20, 2018
2 parents 7855f86 + 097b686 commit ecf297a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
8 changes: 6 additions & 2 deletions jsrts/Runtime-javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ $JSRTS.prim_systemInfo = function (index) {
}
return "";
};
$JSRTS.prim_writeStr = function (x) { return console.log(x) }
$JSRTS.prim_readStr = function () { return prompt('Prelude.getLine') };

$JSRTS.prim_writeStr = function (x) { return console.log(x) };

$JSRTS.prim_readStr = function () { return prompt('Prelude.getLine') };

$JSRTS.die = function (message) { throw new Error(message) };
11 changes: 10 additions & 1 deletion jsrts/Runtime-node.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
$JSRTS.os = require('os');

$JSRTS.fs = require('fs');

$JSRTS.prim_systemInfo = function (index) {
switch (index) {
case 0:
Expand All @@ -9,7 +11,9 @@ $JSRTS.prim_systemInfo = function (index) {
}
return "";
};
$JSRTS.prim_writeStr = function (x) { return process.stdout.write(x) }

$JSRTS.prim_writeStr = function (x) { return process.stdout.write(x) };

$JSRTS.prim_readStr = function () {
var ret = '';
var b = new Buffer(1024);
Expand All @@ -28,4 +32,9 @@ $JSRTS.prim_readStr = function () {
}
}
return ret;
};

$JSRTS.die = function (message) {
console.error(message);
process.exit(-1);
};
2 changes: 1 addition & 1 deletion src/IRTS/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ irTree top args tree = do

irSC :: Name -> Vars -> SC -> Idris LExp
irSC top vs (STerm t) = irTerm top vs [] t
irSC top vs (UnmatchedCase str) = return $ LLazyExp $ LError str
irSC top vs (UnmatchedCase str) = return $ LError str

irSC top vs (ProjCase tm alts) = do
tm' <- irTerm top vs [] tm
Expand Down
2 changes: 1 addition & 1 deletion src/IRTS/JavaScript/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ jsStmt2Text (JsSwitchCase exp l d) =
default2Text Nothing = ""
default2Text (Just z) =
T.concat ["default:\n", indent $ T.concat [jsStmt2Text z, ";\nbreak;\n"]]
jsStmt2Text (JsError t) = T.concat ["throw new Error( ", jsAst2Text t, ");"]
jsStmt2Text (JsError t) = T.concat ["$JSRTS.die(", jsAst2Text t, ");\n"]
jsStmt2Text (JsForever x) =
T.concat ["for(;;) {\n", indent $ jsStmt2Text x, "}\n"]
jsStmt2Text JsContinue = "continue;"
Expand Down

0 comments on commit ecf297a

Please sign in to comment.