diff options
author | 2009-08-11 11:26:37 -0400 | |
---|---|---|
committer | 2009-08-11 11:26:37 -0400 | |
commit | 9b6136387980544fe8c8a8eba41a5fb16d0595c5 (patch) | |
tree | 89728704d7e0ae538803840021a54aa285296084 | |
parent | 9f1c85cf0ef4be94bf189dea486806298f09ab51 (diff) |
Be careful in Jscomp to avoid interpreting non-boolean/reference types as booleans with ?:
-rw-r--r-- | src/jscomp.sml | 8 | ||||
-rw-r--r-- | tests/jsparse.ur | 8 | ||||
-rw-r--r-- | tests/jsparse.urp | 3 | ||||
-rw-r--r-- | tests/jsparse.urs | 1 |
4 files changed, 16 insertions, 4 deletions
diff --git a/src/jscomp.sml b/src/jscomp.sml index d42c659e..f2a48cf3 100644 --- a/src/jscomp.sml +++ b/src/jscomp.sml @@ -585,7 +585,7 @@ fun process file = 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 @@ fun process file = (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 @@ fun process file = 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" diff --git a/tests/jsparse.ur b/tests/jsparse.ur new file mode 100644 index 00000000..de6c9f1a --- /dev/null +++ b/tests/jsparse.ur @@ -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> diff --git a/tests/jsparse.urp b/tests/jsparse.urp new file mode 100644 index 00000000..7f54bfc1 --- /dev/null +++ b/tests/jsparse.urp @@ -0,0 +1,3 @@ +debug + +jsparse diff --git a/tests/jsparse.urs b/tests/jsparse.urs new file mode 100644 index 00000000..6ac44e0b --- /dev/null +++ b/tests/jsparse.urs @@ -0,0 +1 @@ +val main : unit -> transaction page |