Skip to content

Compiling with tail-call optimization optimizes away website #12

@psfblair

Description

@psfblair

Steps to reproduce:

  1. Check out commit 2504a38 of websharper.warp (I was unable to test using earlier commits owing to dependency issues that I didn't have time to iron out. This issue affects subsequent commits as well.)
  2. Build from the command line using build.cmd.
  3. Change to directory build\net45 and run WebSharper.Warp.Test.exe . Make a request on http://127.0.0.1:9000/ so that scripts are compiled.
  4. The browser will return no content (with a 503, 500, or 200 depending on what commit you're testing). The resulting WebSharper.EntryPoint.js will look like this:
(function()
{
 var Global=this,Runtime=this.IntelliFactory.Runtime,EntryPoint;
 Runtime.Define(Global,{
  WebSharper:{
   EntryPoint:{
    Example:Runtime.Field(function()
    {
     return null;
    })
   }
  }
 });
 Runtime.OnInit(function()
 {
  return EntryPoint=Runtime.Safe(Global.WebSharper.EntryPoint);
 });
 Runtime.OnLoad(function()
 {
  EntryPoint.Example();
  return;
 });
}());

Note that there is no click button etc.

  • In Visual Studio 2015/Visual F# 4.0, compile the solution in Release configuration. Run in Visual Studio. Confirm that the WebSharper.EntryPoint.js is the same as above.
  • In Visual Studio, compile in Debug configuration. Run in Visual Studio. The page returned will contain the time and click button. The WebSharper.EntryPoint.js will look like this:
(function()
{
 var Global=this,Runtime=this.IntelliFactory.Runtime,List,Html,Client,Tags,alert,EventsPervasives,EntryPoint;
 Runtime.Define(Global,{
  WebSharper:{
   EntryPoint:{
    Example:Runtime.Field(function()
    {
     return null;
    })
   },
   Warp:{
    Test:{
     Client:{
      Content:function()
      {
       var arg10,x,arg00;
       arg10=List.ofArray([Tags.Tags().text("Click me!")]);
       x=Tags.Tags().NewTag("button",arg10);
       arg00=function()
       {
        return function()
        {
         return alert("Clicked!");
        };
       };
       EventsPervasives.Events().OnClick(arg00,x);
       return x;
      }
     }
    }
   }
  }
 });
 Runtime.OnInit(function()
 {
  List=Runtime.Safe(Global.WebSharper.List);
  Html=Runtime.Safe(Global.WebSharper.Html);
  Client=Runtime.Safe(Html.Client);
  Tags=Runtime.Safe(Client.Tags);
  alert=Runtime.Safe(Global.alert);
  EventsPervasives=Runtime.Safe(Client.EventsPervasives);
  return EntryPoint=Runtime.Safe(Global.WebSharper.EntryPoint);
 });
 Runtime.OnLoad(function()
 {
  EntryPoint.Example();
  return;
 });
}());

Note the code for the click button etc. is present.

  • In Visual Studio, open the properties for the WebSharper.Warp.Test project and select the Build tab. Choose the Release configuration, and un-click the checkbox for "Generate tail calls." Build and run the application in Visual Studio. Confirm that the click button etc. are present and that the WebSharper.EntryPoint.js is the same as is generated in the Debug configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions