diff --git a/lib/gradient/ast_specifier.ex b/lib/gradient/ast_specifier.ex index 8aa4a4f3..9d79f4b9 100644 --- a/lib/gradient/ast_specifier.ex +++ b/lib/gradient/ast_specifier.ex @@ -145,6 +145,7 @@ defmodule Gradient.AstSpecifier do def mapper({:function, anno, name, arity, clauses}, tokens, opts) do # anno has line + opts = Keyword.put(opts, :line, :erl_anno.line(anno)) {clauses, tokens} = context_mapper_fold(clauses, tokens, opts) {:function, anno, name, arity, clauses} diff --git a/test/gradient/ast_specifier_test.exs b/test/gradient/ast_specifier_test.exs index 633daa7e..ef940143 100644 --- a/test/gradient/ast_specifier_test.exs +++ b/test/gradient/ast_specifier_test.exs @@ -1362,6 +1362,19 @@ defmodule Gradient.AstSpecifierTest do ]}} = missing_type end + test "clauses without a line" do + forms = [ + {:function, 8, :__impl__, 1, + [ + {:clause, [generated: true, location: 0], + [{:atom, [generated: true, location: 0], :for}], [], + [{:atom, [generated: true, location: 0], TypedSchemaTest}]} + ]} + ] + + assert [_] = AstSpecifier.run_mappers(forms, []) + end + # Helpers def filter_specs(ast) do