changeset 906:c270fb847dc2

Be careful in Jscomp to avoid interpreting non-boolean/reference types as booleans with ?:
author Adam Chlipala <adamc@hcoop.net>
date Tue, 11 Aug 2009 11:26:37 -0400 (2009-08-11)
parents 7a4b026e45dd
children 5fe49effbc83
files src/jscomp.sml tests/jsparse.ur tests/jsparse.urp tests/jsparse.urs
diffstat 4 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/jscomp.sml	Sun Aug 09 16:13:27 2009 -0400
+++ b/src/jscomp.sml	Tue Aug 11 11:26:37 2009 -0400
@@ -585,7 +585,7 @@
                                         succ,
                                         str ")"]
                               | PCon (Option, _, NONE) =>
-                                strcat [str ("(d" ^ Int.toString depth ^ "?"),
+                                strcat [str ("(d" ^ Int.toString depth ^ "!=null?"),
                                         fail,
                                         str ":",
                                         succ,
@@ -594,7 +594,7 @@
                                 (case IM.find (someTs, n) of
                                      NONE => raise Fail "Jscomp: Not in someTs"
                                    | SOME t =>
-                                     strcat [str ("(d" ^ Int.toString depth ^ "?(d"
+                                     strcat [str ("(d" ^ Int.toString depth ^ "!=null?(d"
                                                   ^ Int.toString (depth+1) ^ "=d" ^ Int.toString depth
                                                   ^ (if isNullable t then
                                                          ".v,"
@@ -634,12 +634,12 @@
                                 in
                                     succ
                                 end
-                              | PNone _ => strcat [str ("(d" ^ Int.toString depth ^ "?"),
+                              | PNone _ => strcat [str ("(d" ^ Int.toString depth ^ "!=null?"),
                                                    fail,
                                                    str ":",
                                                    succ,
                                                    str ")"]
-                              | PSome (t, p) => strcat [str ("(d" ^ Int.toString depth ^ "?(d" ^ Int.toString (depth+1)
+                              | PSome (t, p) => strcat [str ("(d" ^ Int.toString depth ^ "!=null?(d" ^ Int.toString (depth+1)
                                                              ^ "=d" ^ Int.toString depth
                                                              ^ (if isNullable t then
                                                                     ".v"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jsparse.ur	Tue Aug 11 11:26:37 2009 -0400
@@ -0,0 +1,8 @@
+fun main () =
+    s <- source "13";
+    return <xml><body>
+      <ctextbox source={s}/>
+      <dyn signal={v <- signal s; return (case read v : option int of
+                                              None => <xml>None</xml>
+                                            | Some n => <xml>Some {[n]}</xml>)}/>
+      </body></xml>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jsparse.urp	Tue Aug 11 11:26:37 2009 -0400
@@ -0,0 +1,3 @@
+debug
+
+jsparse
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/jsparse.urs	Tue Aug 11 11:26:37 2009 -0400
@@ -0,0 +1,1 @@
+val main : unit -> transaction page