Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-1336

function_clause error not converted to a jump to func_info in comprehension

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Trivial
    • Resolution: Not a Bug
    • Affects Version/s: 23
    • Fix Version/s: None
    • Component/s: compiler
    • Labels:
      None

      Description

      Given the following module:

      -module(test).
      -export([foo/0]).
      
      foo() ->
          [X || X <- lists:seq(1, 10)] ++ [X || X <- lists:seq(11, 20)].
      

      When compiled, the following assembly is produced for the first list comprehension:

      {function, '-foo/0-lc$^1/1-1-', 2, 8}.
        {label,7}.
          {line,[{location,"test.erl",6}]}.
          {func_info,{atom,test},{atom,'-foo/0-lc$^1/1-1-'},2}.
        {label,8}.
          {'%',{var_info,{x,1},[{type,{t_list,any,nil}}]}}.
          {test,is_nonempty_list,{f,9},[{x,0}]}.
          {allocate,1,2}.
          {get_list,{x,0},{y,0},{x,0}}.
          {line,[{location,"test.erl",6}]}.
          {call,2,{f,8}}.
          {'%',{var_info,{x,0},[{type,{t_list,any,nil}}]}}.
          {test_heap,2,1}.
          {put_list,{y,0},{x,0},{x,0}}.
          {deallocate,1}.
          return.
        {label,9}.
          {test,is_nil,{f,10},[{x,0}]}.
          {move,{x,1},{x,0}}.
          return.
        {label,10}.
          {test_heap,2,1}.
          {put_list,{x,0},nil,{x,1}}.
          {move,{atom,function_clause},{x,0}}.
          {line,[{location,"test.erl",6}]}.
          {call_ext_only,2,{extfunc,erlang,error,2}}.
      

      In particular, it fails to optimise the `function_clause` error construction into a jump to the `func_info` label.

        Attachments

          Activity

            People

            Assignee:
            bjorn Björn Gustavsson
            Reporter:
            michalmuskala Michał Muskała
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: