anchor.diff:      to_expr([mset,Map|Ps], L, Vt, St);
   to_expr(['map-update',Map|Ps], L, Vt, St) ->
       to_expr([mupd,Map|Ps], L, Vt, St);
  +to_expr([function,F,Ar], L, Vt, St) ->
  +    Args = new_to_vars(Ar),
  +    Body = [[F|Args]],
  +    to_lambda(Args, Body, L, Vt, St);
  +to_expr([function,M,F,A], L, _, St) -> {{'fun',L,{function,M,F,A}},St};
  +%% Special known data type operations.
   %% Core closure special forms.
  -to_expr([lambda,As|B], L, Vt, St0) ->
  -    {Ecl,St1} = to_fun_cl([As|B], L, Vt, St0),
  -    {{'fun',L,{clauses,[Ecl]}},St1};
  +to_expr([lambda,Args|Body], L, Vt, St) ->
  +    to_lambda(Args, Body, L, Vt, St);
   to_expr(['match-lambda'|Cls], L, Vt, St0) ->
       {Ecls,St1} = to_fun_cls(Cls, L, Vt, St0),
       {{'fun',L,{clauses,Ecls}},St1};
  -to_expr(['fun',F,A], L, _, St) -> {{'fun',L,{function,F,A}},St};
  -to_expr(['fun',M,F,A], L, _, St) -> {{'fun',L,{function,M,F,A}},St};
  -to_expr(['let',Lbs|B], L, Vt0, St0) ->
  +to_expr(['let',Lbs|B], L, Vt, St) ->
  +    to_let(Lbs, B, L, Vt, St);
  +to_expr(['let-function'|_], L, _, _) ->         %Can't do this efficently
  +    illegal_code_error(L, 'let-function');
  +to_expr(['letrec-function'|_], L, _, _) ->      %Can't do this efficently
  +    illegal_code_error(L, 'letrec-function');
  +%% Core control special forms.
  +to_expr([progn|B], L, Vt, St) ->
  +    to_block(B, L, Vt, St);
  +to_expr(['if'|Body], L, Vt, St) ->
  +    to_if(Body, L, Vt, St);
  +to_expr(['case'|Body], L, Vt, St) ->
  +    to_case(Body, L, Vt, St);
  +to_expr(['receive'|Cls], L, Vt, St) ->
  +    to_receive(Cls, L, Vt, St);
  +to_expr(['catch'|B], L, Vt, St0) ->
  +    {Eb,St1} = to_block(B, L, Vt, St0),
  +    {{'catch',L,Eb},St1};
  +to_expr(['try'|Try], L, Vt, St) ->              %Can't do this yet
  +    to_try(Try, L, Vt, St);
  +to_expr([funcall,F|As], L, Vt, St0) ->
  +    {Ef,St1} = to_expr(F, L, Vt, St0),
  +    {Eas,St2} = to_exprs(As, L, Vt, St1),
  +    {{call,L,Ef,Eas},St2};
  +%% Special known macros.
  +%% No record stuff here as they are macros which have been expanded.
  +to_expr([lc,Qs|Es], L, Vt0, St0) ->
  +    {Eqs,Vt1,St1} = to_lc_quals(Qs, L, Vt0, St0),
  +    {Ees,St2} = to_block(Es, L, Vt1, St1),
  +    {{lc,L,Ees,Eqs},St2};
  +%% General function calls.
  +to_expr([call,?Q(erlang),?Q(F)|As], L, Vt, St0) ->
  +    %% This is semantically the same but some tools behave differently
  +    %% (qlc_pt).
  +    {Eas,St1} = to_exprs(As, L, Vt, St0),
  +    case is_erl_op(F, length(As)) of
  +        true -> {list_to_tuple([op,L,F|Eas]),St1};
  +        false ->
  +            {{call,L,{remote,L,{atom,L,erlang},{atom,L,F}},Eas},St1}
  +    end;
  +to_expr([call,M,F|As], L, Vt, St0) ->
  +    {Em,St1} = to_expr(M, L, Vt, St0),
  +    {Ef,St2} = to_expr(F, L, Vt, St1),
  +    {Eas,St3} = to_exprs(As, L, Vt, St2),
  +    {{call,L,{remote,L,Em,Ef},Eas},St3};
  +to_expr([F|As], L, Vt, St0) when is_atom(F) ->  %General function call
  +    {Eas,St1} = to_exprs(As, L, Vt, St0),
  +    Ar = length(As),                            %Arity
  +    case is_erl_op(F, Ar) of
  +        true -> {list_to_tuple([op,L,F|Eas]),St1};
  +        false ->
  +            case lfe_internal:is_lfe_bif(F, Ar) of
  +                true ->
  +                    {{call,L,{remote,L,{atom,L,lfe},{atom,L,F}},Eas},St1};
  +                false ->
  +                    {{call,L,{atom,L,F},Eas},St1}
  +            end
  +    end;
  +to_expr([_|_]=List, L, _, St) ->
  +    case is_posint_list(List) of
  +        true -> {{string,L,List},St};
  +        false ->
  +            illegal_code_error(L, list)         %Not right!
  +    end;
  +to_expr(V, L, Vt, St) when is_atom(V) ->        %Unquoted atom
  +    to_expr_var(V, L, Vt, St);
  +to_expr(Lit, L, _, St) ->                       %Everything else is a literal
  +    {to_lit(Lit, L),St}.
  +
  +to_expr_var(V, L, Vt, St) ->
  +    Var = ?VT_GET(V, Vt, V),                    %Hmm
  +    {{var,L,Var},St}.
  +
  +%% is_erl_op(Op, Arity) -> bool().
  +%% Is Op/Arity one of the known Erlang operators?
  +
  +is_erl_op(Op, Ar) ->
  +    erl_internal:arith_op(Op, Ar)
  +    orelse erl_internal:bool_op(Op, Ar)
  +    orelse erl_internal:comp_op(Op, Ar)
  +    orelse erl_internal:list_op(Op, Ar)
  +    orelse erl_internal:send_op(Op, Ar).
  +
  +to_body(Es, L, Vt, St) ->
  +    Fun = fun (E, St0) -> to_expr(E, L, Vt, St0) end,
  +    mapfoldl(Fun, St, Es).
  +
  +to_exprs(Es, L, Vt, St) ->
  +    Fun = fun (E, St0) -> to_expr(E, L, Vt, St0) end,
  +    mapfoldl(Fun, St, Es).
  +
  +to_exprs_s(Fun, L, Vt, St, [E]) -> Fun(E, L, Vt, St);
  +to_exprs_s(Fun, L, Vt, St0, [E|Es]) ->
  +    {Les,St1} = to_exprs_s(Fun, L, Vt, St0, Es),
  +    {Le,St2} = Fun(E, L, Vt, St1),
  +    {{cons,L,Le,Les},St2};
  +to_exprs_s(_, L, _, St, []) -> {{nil,L},St}.
  +
  +to_pats_s(Fun, L, Pvs, Vt, St, [E]) -> Fun(E, L, Pvs, Vt, St);
  +to_pats_s(Fun, L, Pvs0, Vt0, St0, [E|Es]) ->
  +    {Les,Pvs1,Vt1,St1} = to_pats_s(Fun, L, Pvs0, Vt0, St0, Es),
  +    {Le,Pvs2, Vt2,St2} = Fun(E, L, Pvs1, Vt1, St1),
  +    {{cons,L,Le,Les},Pvs2,Vt2,St2};
  +to_pats_s(_, L, Pvs, Vt, St, []) -> {{nil,L},Pvs,Vt,St}.
  +
  +%% to_bitsegs(Segs, LineNumber, VarTable, State) -> {Segs,State}.
  +%% This gives a verbose value, but it is correct.
  +
  +to_bitsegs(Ss, L, Vt, St) ->
  +    Fun = fun (S, St0) -> to_bitseg(S, L, Vt, St0) end,
  +    mapfoldl(Fun, St, Ss).
  +
  +to_bitseg([Val|Specs]=F, L, Vt, St) ->
  +    case is_posint_list(F) of
  +        true ->
  +            {Size,Type} = to_bitspecs([], L),
  +            to_bin_element(F, Size, Type, L, Vt, St);
  +        false ->
  +            {Size,Type} = to_bitspecs(Specs, []),
  +            to_bin_element(Val, Size, Type, L, Vt, St)
  +    end;
  +to_bitseg(Val, L, Vt, St) ->
  +    {Size,Type} = to_bitspecs([], L),
  +    to_bin_element(Val, Size, Type, L, Vt, St).
  +
  +to_bin_element(Val, Size, {Type,Unit,Sign,End}, L, Vt, St0) ->
  +    {Eval,St1} = to_expr(Val, L, Vt, St0),
  +    {Esiz,St2} = to_bin_size(Size, L, Vt, St1),
  +    {{bin_element,L,Eval,Esiz,[Type,to_bin_unit(Unit),Sign,End]},St2}.
  +
  +to_bin_size(default, _, _, St) -> {default,St};
  +to_bin_size(undefined, _, _, St) -> {default,St};
  +to_bin_size(Size, L, Vt, St) -> to_expr(Size, L, Vt, St).
  +
  +to_bin_unit(default) -> default;
  +to_bin_unit(Unit) -> {unit,Unit}.
  +
  +%% to_bitspec(Specs, Line) -> {Size,Type}.
  +%%  Get the error handling as we want it.
  +
  +to_bitspecs(Ss, L) ->
  +    case lfe_bits:get_bitspecs(Ss) of
  +        {ok,Sz,Ty} -> {Sz,Ty};
  +        {error,Error} -> illegal_code_error(L, Error)
  +    end.
  +
  +%% to_map_pairs(Pairs, LineNumber, VarTable, State) -> {Fields,State}.
  +
  +to_map_pairs([K,V|Ps], Field, L, Vt, St0) ->
  +    {Ek,St1} = to_expr(K, L, Vt, St0),
  +    {Ev,St2} = to_expr(V, L, Vt, St1),
  +    {Eps,St3} = to_map_pairs(Ps, Field, L, Vt, St2),
  +    {[{Field,L,Ek,Ev}|Eps],St3};
  +to_map_pairs([], _, _, _, St) -> {[],St}.
  +
  +%% to_fun_cls(Clauses, LineNumber) -> Clauses.
  +%% to_fun_cl(Clause, LineNumber) -> Clause.
  +%%  Function clauses.
  +
  +to_fun_cls(Cls, L, Vt, St) ->
  +    Fun = fun (Cl, St0) -> to_fun_cl(Cl, L, Vt, St0) end,
  +    mapfoldl(Fun, St, Cls).
  +
  +to_fun_cl([As,['when']|B], L, Vt0, St0) ->
  +    {Eas,Vt1,St1} = to_pats(As, L, Vt0, St0),
  +    {Eb,St2} = to_body(B, L, Vt1, St1),
  +    {{clause,L,Eas,[],Eb},St2};
  +to_fun_cl([As,['when'|G]|B], L, Vt0, St0) ->
  +    {Eas,Vt1,St1} = to_pats(As, L, Vt0, St0),
  +    {Eg,St2} = to_body(G, L, Vt1, St1),
  +    {Eb,St3} = to_body(B, L, Vt1, St2),
  +    {{clause,L,Eas,[Eg],Eb},St3};
  +to_fun_cl([As|B], L, Vt0, St0) ->
  +    {Eas,Vt1,St1} = to_pats(As, L, Vt0, St0),
  +    {Eb,St2} = to_body(B, L, Vt1, St1),
  +    {{clause,L,Eas,[],Eb},St2}.
  +
  +%% to_lambda(Args, Body, LineNumber, VarTable, State) -> {Lambda,State}.
  +
  +to_lambda(As, B, L, Vt, St0) ->
  +    {Ecl,St1} = to_fun_cl([As|B], L, Vt, St0),
  +    {{'fun',L,{clauses,[Ecl]}},St1}.
  +
  +%% to_let(VarBindings, Body, LineNumber, VarTable, State) -> {Block,State}.
  +
  +to_let(Lbs, B, L, Vt0, St0) ->
       {Ebs,Vt1,St1} = to_let_bindings(Lbs, L, Vt0, St0),
       {Eb,St2} = to_body(B, L, Vt1, St1),
  -    {{block,L,Ebs ++ Eb},St2};
  -%% Core control special forms.
  -to_expr([progn|B], L, Vt, St) -> to_block(B, L, Vt, St);
  -to_expr(['if',Test,True], L, Vt, St) ->
  -    to_expr(['if',Test,True,?Q(false)], L, Vt, St);
  -to_expr(['if',Test,True,False], L, Vt, St0) ->
  +    {{block,L,Ebs ++ Eb},St2}.
  +
  +%% to_let_bindings(Bindings, LineNumber, VarTable, State) ->
  +%%     {Block,VarTable,State}.
  +%%  When we have a guard translate into a case but special case where
  +%%  we have an empty guard as erlang compiler doesn't like this.
  +
  +to_let_bindings(Lbs, L, Vt, St) ->
  +    Fun = fun ([P,E], Vt0, St0) ->
  +                  {Ep,Vt1,St1} = to_pat(P, L, Vt0, St0),
  +                  {Ee,St2} = to_expr(E, L, Vt0, St1),
  +                  {{match,L,Ep,Ee},Vt1,St2};
  +              ([P,['when'],E], Vt0, St0) ->     %Just to keep it short
  +                  {Ep,Vt1,St1} = to_pat(P, L, Vt0, St0),
  +                  {Ee,St2} = to_expr(E, L, Vt0, St1),
  +                  {{match,L,Ep,Ee},Vt1,St2};
  +              ([P,['when'|G],E], Vt0, St0) ->
  +                  {Ep,Vt1,St1} = to_pat(P, L, Vt0, St0),
  +                  {Eg,St2} = to_body(G, L, Vt1, St1),
  +                  {Ee,St3} = to_expr(E, L, Vt1, St2),
  +                  {{'case',L,Ee,[{clause,L,[Ep],[Eg],[Ep]}]},Vt1,St3}
  +          end,
  +    mapfoldl2(Fun, Vt, St, Lbs).
  +
  +%% to_block(Expressions, LineNumber, VarTable, State) -> {Block,State}.
  +%%  Don't generate {block,...} if only one expression, though
  +%%  semantically the same some tools can't handle it (qlc_pt).
  +
  +to_block(Es, L, Vt, St0) ->
  +    case to_exprs(Es, L, Vt, St0) of
  +        {[Ee],St1} -> {Ee,St1};                 %No need to wrap
  +        {Ees,St1} -> {{block,L,Ees},St1}        %Must wrap
  +    end.
  +
  +%% to_if(IfBody, LineNumber, VarTable, State) -> {ErlCase,State}.
  +
  +to_if([Test,True], L, Vt, St) ->
  +    to_if(Test, True, ?Q(false), L, Vt, St);
  +to_if([Test,True,False], L, Vt, St) ->
  +    to_if(Test, True, False, L, Vt, St);
  +to_if(_, L, _, _) ->
  +    illegal_code_error(L, 'if').
  +
  +to_if(Test, True, False, L, Vt, St0) ->
       {Etest,St1} = to_expr(Test, L, Vt, St0),
       {Ecls,St2} = to_icrt_cls([[?Q(true),True],[?Q(false),False]], L, Vt, St1),
  -    {{'case',L,Etest,Ecls},St2};
  -to_expr(['case',E|Cls], L, Vt, St0) ->
  +    {{'case',L,Etest,Ecls},St2}.
  +
  +%% to_case(CaseBody, LineNumber, VarTable, State) -> {ErlCase,State}.
  +
  +to_case([E|Cls], L, Vt, St0) ->
       {Ee,St1} = to_expr(E, L, Vt, St0),
       {Ecls,St2} = to_icrt_cls(Cls, L, Vt, St1),
       {{'case',L,Ee,Ecls},St2};
  -to_expr(['receive'|Cls0], L, Vt, St0) ->
  +to_case(_, L, _, _) ->
  +    illegal_code_error(L, 'case').
  +
  +%% to_receive(RecClauses, LineNumber, VarTable, State) -> {ErlRec,State}.
  +
  +to_receive(Cls0, L, Vt, St0) ->
       %% Get the right receive form depending on whether there is an after.
       {Cls1,A} = splitwith(fun (['after'|_]) -> false; (_) -> true end, Cls0),
       {Ecls,St1} = to_icrt_cls(Cls1, L, Vt, St0),
  
positive.code:     {Lf,Vt1,St1} = from_expr(F, Vt0, St0),
      {Las,Vt2,St2} = from_expr_list(As, Vt1, St1),
      {[funcall,Lf|Las],Vt2,St2};
  from_expr({'try',_,Es,Scs,Ccs,As}, Vt, St0) ->
      %% Currently erl_lint does not allow any exports!
      {Les,_,St1} = from_body(Es, Vt, St0),
      %% These maybe empty.
      {Lscs,_,St2} = if Scs =:= [] -> {[],[],St1};
                        true -> from_icrt_cls(Scs, Vt, St1)
                     end,
      {Lccs,_,St3} = if Ccs =:= [] -> {[],[],St2};
                        true -> from_icrt_cls(Ccs, Vt, St2)
                     end,
      {Las,_,St4} = from_body(As, Vt, St3),
      {['try',[progn|Les]|
        from_maybe('case', Lscs) ++
            from_maybe('catch', Lccs) ++
            from_maybe('after', Las)],Vt,St4};
  from_expr({'catch',_,E}, Vt0, St0) ->
      {Le,Vt1,St1} = from_expr(E, Vt0, St0),
      {['catch',Le],Vt1,St1};
  from_expr({match,L,P,E}, Vt0, St0) ->
      {Alias,St1} = new_from_var(St0),            %Alias variable value
      MP = {match,L,{var,L,Alias},P},
      {Lp,Eqt,Vt1,St2} = from_pat(MP, Vt0, St1),  %The alias pattern
      {Le,Vt2,St3} = from_expr(E, Vt1, St2),      %The expression
      Leg = from_eq_tests(Eqt),                   %Implicit guard tests
      {['let',[[Lp,['when'|Leg],Le]],Alias],Vt2,St3};
  from_expr({op,_,Op,A}, Vt0, St0) ->
      {La,Vt1,St1} = from_expr(A, Vt0, St0),
      {[Op,La],Vt1,St1};
  
negative.code: %% Copyright (c) 2008-2018 Robert Virding
  %%
  %% Licensed under the Apache License, Version 2.0 (the "License");
  %% you may not use this file except in compliance with the License.
  