diff options
author | Björn Gustavsson <[email protected]> | 2014-03-19 16:17:22 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2014-10-27 15:41:16 +0100 |
commit | bad6a90f51a4e66a0c17910ff2791aaa09c564a1 (patch) | |
tree | b8e202c680ef1bf3e366c886e8bbb13bc2c12c45 /lib | |
parent | 50f396e81ad3a3f815c8ac42b78b284b4941bece (diff) | |
download | otp-bad6a90f51a4e66a0c17910ff2791aaa09c564a1.tar.gz otp-bad6a90f51a4e66a0c17910ff2791aaa09c564a1.tar.bz2 otp-bad6a90f51a4e66a0c17910ff2791aaa09c564a1.zip |
Extract annotations from filter qualifiers in a type-friendly way
Commit 78ce8917d started to use get_anno/1 to extract the line
annotation from filter qualifiers in comprehensions, but this does not
respect the spec of this function and resuls in a dialyzer warning.
To make the code more type-friendly, introduce a get_qual_anno/1
function.
Kostis Sagonas suggested that the function should be implemented
similar to this to also ensure that the qualifiers are of the
appropriate form:
get_qual_anno({call,Line,_,_}) -> Line;
get_qual_anno({op,Line,_,_,_}) -> Line;
.
.
.
get_qual_anno({var,Line,_}) -> Line.
The problem is that it is difficult to know exacly which forms
that may occur and the function will need to be updated if new
abstract forms are added. Thus this implementation would complicate
maintanance without any real payoff.
Reported-by: Kostis Sagonas
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/src/v3_core.erl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl index 3d9fc3a609..6b9450e481 100644 --- a/lib/compiler/src/v3_core.erl +++ b/lib/compiler/src/v3_core.erl @@ -1173,7 +1173,7 @@ preprocess_quals(Line, [Q|Qs0], St0, Acc) -> {Gen,St} = generator(Line, Q, Gs, St0), preprocess_quals(Line, Qs, St, [Gen|Acc]); false -> - LAnno = #a{anno=lineno_anno(get_anno(Q), St0)}, + LAnno = #a{anno=lineno_anno(get_qual_anno(Q), St0)}, case is_guard_test(Q) of true -> %% When a filter is a guard test, its argument in the @@ -1198,6 +1198,11 @@ is_generator({generate,_,_,_}) -> true; is_generator({b_generate,_,_,_}) -> true; is_generator(_) -> false. +%% Retrieve the annotation from an Erlang AST form. +%% (Use get_anno/1 to retrieve the annotation from Core Erlang forms). + +get_qual_anno(Abstract) -> element(2, Abstract). + %% %% Generators are abstracted as sextuplets: %% - acc_pat is the accumulator pattern, e.g. [Pat|Tail] for Pat <- Expr. |