alpaca icon indicating copy to clipboard operation
alpaca copied to clipboard

ADT argument in function header crashes compiler

Open tim2CF opened this issue 5 years ago • 0 comments

type maybe 'a = Just 'a | Nothing

val (>>=) 'a 'b : fn (maybe 'a) (fn 'a -> maybe 'b) -> (maybe 'b)
let (>>=) (Nothing) _ = Nothing
let (>>=) (Just x) f = f x

code crashes compiler

== Compiling 1 Alpaca source files
Function: '(>>=)'/2
: internal error in sys_core_fold;
crash reason: {case_clause,{'EXIT',{{case_clause,{<<"pat_var_1">>,#{}}},
                      [{sys_core_fold,'-sub_add_scope/2-anonymous-0-',2,
                                      [{file,"sys_core_fold.erl"},
                                       {line,1521}]},
                       {lists,foldl,3,[{file,"lists.erl"},{line,1263}]},
                       {sys_core_fold,sub_add_scope,2,
                                      [{file,"sys_core_fold.erl"},
                                       {line,1521}]},
                       {sys_core_fold,pattern,3,
                                      [{file,"sys_core_fold.erl"},
                                       {line,1302}]},
                       {lists,mapfoldl,3,[{file,"lists.erl"},{line,1354}]},
                       {sys_core_fold,expr,3,
                                      [{file,"sys_core_fold.erl"},{line,301}]},
                       {sys_core_fold,find_fixpoint,3,
                                      [{file,"sys_core_fold.erl"},{line,141}]},
                       {sys_core_fold,function_1,1,
                                      [{file,"sys_core_fold.erl"},
                                       {line,127}]}]}}}

  in function  compile:'-select_passes/2-anonymous-2-'/3 (compile.erl, line 672)
  in call from compile:'-internal_comp/5-anonymous-1-'/3 (compile.erl, line 396)
  in call from compile:fold_comp/4 (compile.erl, line 423)
  in call from compile:internal_comp/5 (compile.erl, line 407)
  in call from compile:'-do_compile/2-anonymous-0-'/2 (compile.erl, line 207)
  in call from compile:'-do_compile/2-anonymous-1-'/1 (compile.erl, line 223)
** (MatchError) no match of right hand side value: :error
    /Users/itkachuk/MYprojects/alpaca_mix_compiler/example/deps/alpaca/src/alpaca.erl:157: :alpaca.compile_module/2
    (stdlib) lists.erl:1239: :lists.map/2
    /Users/itkachuk/MYprojects/alpaca_mix_compiler/example/deps/alpaca/src/alpaca.erl:108: :alpaca.compile_phase_4/2
    lib/mix/tasks/compile.alpaca.ex:36: Mix.Tasks.Compile.Alpaca.do_run/3
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/compile.all.ex:68: Mix.Tasks.Compile.All.run_compiler/2
    (mix) lib/mix/tasks/compile.all.ex:52: Mix.Tasks.Compile.All.do_compile/4
    (mix) lib/mix/tasks/compile.all.ex:23: anonymous fn/1 in Mix.Tasks.Compile.All.run/1

tim2CF avatar May 20 '19 20:05 tim2CF