# HG changeset patch # User Adam Chlipala # Date 1395089530 14400 # Node ID 057b08253a75100bd648155ea39b6aa29dd85394 # Parent 94529780bbcfbef70135f98d4c68aa541d1f1e4f -explainEmbed diff -r 94529780bbcf -r 057b08253a75 doc/manual.tex --- a/doc/manual.tex Fri Mar 07 11:50:45 2014 -0500 +++ b/doc/manual.tex Mon Mar 17 16:52:10 2014 -0400 @@ -266,6 +266,8 @@ \item \texttt{-dumpSource}: When compilation fails, output to stderr the complete source code of the last intermediate program before the compilation phase that signaled the error. (Warning: these outputs can be very long and aren't especially optimized for readability!) +\item \texttt{-explainEmbed}: Trigger more verbose error messages about inability to embed server-side values in client-side code. + \item \texttt{-limit class num}: Equivalent to the \texttt{limit} directive from \texttt{.urp} files \item \texttt{-moduleOf FILENAME}: Prints the Ur/Web module name corresponding to source file \texttt{FILENAME}, exiting immediately afterward. diff -r 94529780bbcf -r 057b08253a75 src/jscomp.sig --- a/src/jscomp.sig Fri Mar 07 11:50:45 2014 -0500 +++ b/src/jscomp.sig Mon Mar 17 16:52:10 2014 -0400 @@ -29,4 +29,8 @@ val process : Mono.file -> Mono.file + val explainEmbed : bool ref + (* Output verbose error messages about inability to embed server-side + * values in client-side code? *) + end diff -r 94529780bbcf -r 057b08253a75 src/jscomp.sml --- a/src/jscomp.sml Fri Mar 07 11:50:45 2014 -0500 +++ b/src/jscomp.sml Mon Mar 17 16:52:10 2014 -0400 @@ -41,6 +41,8 @@ val compare = U.Typ.compare end) +val explainEmbed = ref false + type state = { decls : (string * int * (string * int * typ option) list) list, script : string list, @@ -267,7 +269,12 @@ ((EApp ((ENamed n', loc), e), loc), st) end) - | _ => ((*Print.prefaces "Can't embed" [("t", MonoPrint.p_typ MonoEnv.empty t)];*) + | _ => (if !explainEmbed then + Print.prefaces "Can't embed" [("loc", Print.PD.string (ErrorMsg.spanToString loc)), + ("e", MonoPrint.p_exp MonoEnv.empty e), + ("t", MonoPrint.p_typ MonoEnv.empty t)] + else + (); raise CantEmbed t) fun unurlifyExp loc (t : typ, st) = @@ -400,6 +407,9 @@ fun jsE inner (e as (_, loc), st) = let + (*val () = Print.prefaces "jsExp" [("e", MonoPrint.p_exp MonoEnv.empty e), + ("loc", Print.PD.string (ErrorMsg.spanToString loc))]*) + val str = str loc fun patCon pc = diff -r 94529780bbcf -r 057b08253a75 src/main.mlton.sml --- a/src/main.mlton.sml Fri Mar 07 11:50:45 2014 -0500 +++ b/src/main.mlton.sml Mon Mar 17 16:52:10 2014 -0400 @@ -174,6 +174,9 @@ else Settings.addLimit (class, n); doArgs rest) + | "-explainEmbed" :: rest => + (JsComp.explainEmbed := true; + doArgs rest) | arg :: rest => (if size arg > 0 andalso String.sub (arg, 0) = #"-" then raise Fail ("Unknown flag " ^ arg)