Skip to content

Commit 76bb876

Browse files
committed
Add in_guard field to state
This will be used later to determine the type of compilation needed for functions within a guard
1 parent b74c6e9 commit 76bb876

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

lib/elixir_script/passes/translate/clause.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ defmodule ElixirScript.Translate.Clause do
9393
end
9494

9595
def compile_guard(params, guards, state) do
96+
state = Map.put(state, :in_guard, true)
9697

9798
guards = guards
9899
|> List.wrap

lib/elixir_script/passes/translate/function.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ defmodule ElixirScript.Translate.Function do
1212
anonymous? = Map.get(state, :anonymous_fn, false)
1313

1414
state = Map.put(state, :anonymous_fn, true)
15+
|> Map.put(:in_guard, false)
16+
1517
clauses = compile_clauses(clauses, state)
1618

1719
arg_matches_declaration = Helpers.declare_let("__arg_matches__", J.identifier("null"))
@@ -51,6 +53,7 @@ defmodule ElixirScript.Translate.Function do
5153
def compile({{name, arity}, _type, _, clauses}, state) do
5254
state = Map.put(state, :function, {name, arity})
5355
|> Map.put(:anonymous_fn, false)
56+
|> Map.put(:in_guard, false)
5457

5558
clauses = compile_clauses(clauses, state)
5659

0 commit comments

Comments
 (0)