[Ur] Invalid Action expression

Adam Chlipala adamc at csail.mit.edu
Tue Jul 22 08:42:39 EDT 2014


Here we have an interesting interaction between the ordering of compiler 
phases.

Ur/Web links (including in <submit> actions) must be calls to named 
functions defined at the top levels of modules, more or less.  While the 
body of [sbm] instead uses a local variable for a link, we know, of 
course, that inlining the definition of [sbm] leads to a concrete 
function name instead.  Unfortunately, the current Ur/Web compiler is 
not going to inline the call, because the phase that does inlining runs 
/after/ the phase that produces URL-generation code!  I think this 
ordering choice is actually the right one, because inlining can change 
which syntactic function name appears in an 'action' attribute, etc., 
potentially leading to unintuitive behavior in URL generation (e.g., a 
link written as a call to a particular named function actually winds up 
compiled as a call to different named function, because of inlining).

Probably the easiest way to implement your abstraction is via a functor, 
using the module system.  Functor applications get inlined fully before 
producing URL-generation code.

Even better, though, could be to stop using 20th-century forms and use 
client-side scripting with <button>, etc., instead!

On 07/20/2014 04:08 PM, Sergey Mironov wrote:
> Hi! Here is another error I've faced when trying to write a
> styling-wrapper for my submit buttons:
>
> $ urweb -dbms sqlite Submit
> /home/grwlf/proj/urbugs/Submit.ur:21:89: (to 21:90) Invalid Action expression
> Expression UNBOUND_0
>
> See the trivial example below. Please, consider fixing! Without
> sbm-like wrappers I am forced to repeat submit code from form to
> form..
> Regards,
> Sergey
>
> --
>
> style mystyle
>
> con ct = [A = string, B = string]
>
> fun handler (x:$ct) : transaction page = return
> <xml><head/><body>{[x.A]}{[x.B]}</body></xml>
>
> fun sbm [t:::{Type}] (h : $t -> transaction page) : xml form t [] =
> <xml><div class={mystyle}><submit action={h}
> value="Send"/></div></xml>
>
> fun main {} = return <xml><head/><body>
>    <br/>
>    <form>
>    <textbox{#A}/>
>    <textbox{#B}/>
>    {sbm handler}
>    </form>
>    </body></xml>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.impredicative.com/pipermail/ur/attachments/20140722/e128ff01/attachment-0001.html>


More information about the Ur mailing list