Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalization & Truncation Error Fixes #146

Merged
merged 3 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/sobelow/parse.ex
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,17 @@ defmodule Sobelow.Parse do
{finding, List.flatten(opts)}
end

# This handles normalizations for the case where the finding is a dot-access tuple
def normalize_finding({finding, {:., _, [{var, _, _}, field]}}) when is_atom(field) do
{finding, "#{atom_to_string(var)}.${atom_to_string(field)}"}
end

def normalize_finding({finding, opt}) do
{finding, [opt]}
end

defp atom_to_string(atom) when is_atom(atom), do: Atom.to_string(atom)

def get_erlang_funs_of_type(ast, type) do
{_, acc} = Macro.prewalk(ast, [], &get_erlang_funs_of_type(&1, &2, type, :erlang))
acc
Expand Down Expand Up @@ -455,7 +462,7 @@ defmodule Sobelow.Parse do
end

defp create_fun_cap(fun, meta, idx) when is_number(idx) do
opts = Enum.map(1..idx, fn i -> {:&, [], [i]} end)
opts = Enum.map(1..trunc(idx), fn i -> {:&, [], [i]} end)
{fun, meta, opts}
end

Expand Down
Loading