# HG changeset patch # User Adam Chlipala # Date 1242506268 14400 # Node ID c1f8963ebb186d256f0c2e409af0ae0894d64faf # Parent 81fce435e2551a76ee31952df22dfa046d24fbe2 Fix another problem with overwrites during JavaScript pattern matching diff -r 81fce435e255 -r c1f8963ebb18 lib/js/urweb.js --- a/lib/js/urweb.js Sat May 16 16:02:17 2009 -0400 +++ b/lib/js/urweb.js Sat May 16 16:37:48 2009 -0400 @@ -30,8 +30,8 @@ throw msg; } -function pf() { - whine("Pattern match failure"); +function pf(loc) { + whine("Pattern match failure (" + loc + ")"); } function runHandlers(kind, ls, arg) { diff -r 81fce435e255 -r c1f8963ebb18 src/jscomp.sml --- a/src/jscomp.sml Sat May 16 16:02:17 2009 -0400 +++ b/src/jscomp.sml Sat May 16 16:37:48 2009 -0400 @@ -457,7 +457,7 @@ ^ ":" ^ e, st) end) - ("pf()", st) cs + ("pf(\"" ^ ErrorMsg.spanToString loc ^ "\")", st) cs val body = "function _n" ^ Int.toString n' ^ "(t,i){var x=t[i++];var r=" ^ e ^ ";return {_1:i,_2:r}}\n\n" @@ -573,13 +573,13 @@ (case IM.find (someTs, n) of NONE => raise Fail "Jscomp: Not in someTs" | SOME t => - strcat [str ("(d" ^ Int.toString depth ^ "?(" + strcat [str ("(d" ^ Int.toString depth ^ "?(d" + ^ Int.toString (depth+1) ^ "=d" ^ Int.toString depth ^ (if isNullable t then - "d" ^ Int.toString depth ^ "=d" - ^ Int.toString depth ^ ".v," + ".v," else "")), - jsPat depth inner p succ fail, + jsPat (depth+1) inner p succ fail, str "):", fail, str ")"]) @@ -594,8 +594,8 @@ | PCon (_, pc, SOME p) => strcat [str ("(d" ^ Int.toString depth ^ ".n=="), patCon pc, - str ("?(d" ^ Int.toString depth ^ "=d" ^ Int.toString depth ^ ".v,"), - jsPat depth inner p succ fail, + str ("?(d" ^ Int.toString (depth+1) ^ "=d" ^ Int.toString depth ^ ".v,"), + jsPat (depth+1) inner p succ fail, str "):", fail, str ")"] @@ -898,7 +898,7 @@ val (e, st) = jsE (inner + E.patBindsN p) (e, st) val fail = if i = plen - 1 then - str "pf()" + str ("pf(\"" ^ ErrorMsg.spanToString loc ^ "\")") else str ("c" ^ Int.toString (i+1) ^ "()") val c = jsPat 0 inner p e fail