Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix _ variable bug in pattern compilation

  • Loading branch information...
commit afde87d5872088de8c50a80668a8aa6c2808cc98 1 parent 2be6f31
Eric Merritt ericbmerritt authored

Showing 1 changed file with 14 additions and 1 deletion. Show diff stats Hide diff stats

  1. +14 1 src/jxa_clause.erl
15 src/jxa_clause.erl
@@ -15,6 +15,14 @@
15 15 comp(Path0, Ctx0, Clauses) ->
16 16 comp(Path0, Ctx0, Clauses, []).
17 17
  18 +comp_pattern(Path0, {Ctx0, Guards0}, '_') ->
  19 + {_, {Line, _}} = jxa_annot:get(jxa_path:path(Path0),
  20 + jxa_ctx:annots(Ctx0)),
  21 + Gensym = erlang:list_to_atom("_" ++ erlang:atom_to_list(joxa:gensym())),
  22 +
  23 + CerlVar = cerl:ann_c_var([Line], Gensym),
  24 + Ctx1 = jxa_ctx:add_variable_to_scope(Gensym, Ctx0),
  25 + {{Ctx1, Guards0}, CerlVar};
18 26 comp_pattern(Path0, {Ctx0, Guards0}, Arg) when is_atom(Arg) ->
19 27 {_, {Line, _}} = jxa_annot:get(jxa_path:path(Path0),
20 28 jxa_ctx:annots(Ctx0)),
@@ -205,7 +213,12 @@ compile_clause_body(Path0, Ctx0, [Pattern, Body]) ->
205 213 {jxa_ctx:pop_scope(Ctx3),
206 214 cerl:ann_c_clause([Line], [CerlPattern],
207 215 CompleteGuards,
208   - CerlBody)}.
  216 + CerlBody)};
  217 +compile_clause_body(Path0, Ctx0, _) ->
  218 + {_, Idx} = jxa_annot:get(jxa_path:path(Path0),
  219 + jxa_ctx:annots(Ctx0)),
  220 + ?JXA_THROW({invalid_case_clause, Idx}).
  221 +
209 222
210 223 mk_tuple(Path0, Acc0, Args) ->
211 224 {_, Acc3={Ctx0, _}, Body} =

0 comments on commit afde87d

Please sign in to comment.
Something went wrong with that request. Please try again.